Object.prototype
builtins should not be used directly JS-0021575 return e3.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
576 }, t2.getNextSafeSlug = function(e3, t3) {
577 var u2 = e3, n2 = 0;
578 if (this.seen.hasOwnProperty(u2))579 for (n2 = this.seen[e3]; u2 = e3 + "-" + ++n2, this.seen.hasOwnProperty(u2); )
580 ;
581 return t3 || (this.seen[e3] = n2, this.seen[u2] = 0), u2;
576 }, t2.getNextSafeSlug = function(e3, t3) {
577 var u2 = e3, n2 = 0;
578 if (this.seen.hasOwnProperty(u2))
579 for (n2 = this.seen[e3]; u2 = e3 + "-" + ++n2, this.seen.hasOwnProperty(u2); )580 ;
581 return t3 || (this.seen[e3] = n2, this.seen[u2] = 0), u2;
582 }, t2.slug = function(e3, t3) {
666 return e3.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-");
667 }, t2.getNextSafeSlug = function(e3, t3) {
668 var u2 = e3, n2 = 0;
669 if (this.seen.hasOwnProperty(u2)) {670 n2 = this.seen[e3];
671 do {
672 u2 = e3 + "-" + ++n2;
670 n2 = this.seen[e3];
671 do {
672 u2 = e3 + "-" + ++n2;
673 } while (this.seen.hasOwnProperty(u2));674 }
675 return t3 || (this.seen[e3] = n2, this.seen[u2] = 0), u2;
676 }, t2.slug = function(e3, t3) {
8174 getNextSafeSlug(originalSlug, isDryRun) {
8175 let slug = originalSlug;
8176 let occurenceAccumulator = 0;
8177 if (this.seen.hasOwnProperty(slug)) { 8178 occurenceAccumulator = this.seen[originalSlug];
8179 do {
8180 occurenceAccumulator++;
It is preferable to call certain Object.prototype
methods through Object
on object instances instead of using the builtins directly.
Objects can have properties that shadow the builtins on Object.prototype
, potentially causing unintended behavior or denial-of-service security vulnerabilities.
For example, it would be unsafe for a webserver to parse JSON input from a client and call hasOwnProperty
directly on the resulting object, because a malicious client could send a JSON value like {"hasOwnProperty": 1}
and cause the server to crash.
It's better to always call these methods from Object.prototype
. For example, obj.hasOwnProperty("bar")
should be replaced with Object.prototype.hasOwnProperty.call(obj, "bar")
.
let hasBarProperty = obj.hasOwnProperty("property");
let isPrototypeOfBar = obj.isPrototypeOf(property);
let barIsEnumerable = obj.propertyIsEnumerable("property");
let hasBarProperty = Object.prototype.hasOwnProperty.call(obj, "property");
let isPrototypeOfBar = Object.prototype.isPrototypeOf.call(obj, property);
let barIsEnumerable = {}.propertyIsEnumerable.call(obj, "property");