fix: improve test regex to validate disallowed methods that can be bypassed by prototype reassignments and/or otherwise (#38214)

* fix: improve test regex to validate disallowed methods that can be bypassed by prototype reassignments and/or otherwise

* fix: fixing regex pattern
This commit is contained in:
Hassaan Pasha
2020-03-26 20:13:34 +05:00
committed by GitHub
parent bb7a50e341
commit 4fbce07792
13 changed files with 18 additions and 16 deletions

View File

@ -33,7 +33,7 @@ tests:
- text: Your code should use the <code>concat</code> method.
testString: assert(code.match(/\.concat/g));
- text: Your code should not use the <code>push</code> method.
testString: assert(!code.match(/\.push/g));
testString: assert(!code.match(/\.?[\s\S]*?push/g));
- text: The <code>first</code> array should not change.
testString: assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]));
- text: The <code>second</code> array should not change.

View File

@ -29,7 +29,7 @@ tests:
- text: The <code>globalTitle</code> variable should not change.
testString: assert(globalTitle === "Winter Is Coming");
- text: Your code should not use the <code>replace</code> method for this challenge.
testString: assert(!code.match(/\.replace/g));
testString: assert(!code.match(/\.?[\s\S]*?replace/g));
- text: <code>urlSlug("Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.
testString: assert(urlSlug("Winter Is Coming") === "winter-is-coming");
- text: <code>urlSlug(" Winter Is &nbsp;Coming")</code> should return <code>"winter-is-coming"</code>.

View File

@ -31,7 +31,7 @@ tests:
- text: Your code should use the <code>join</code> method.
testString: assert(code.match(/\.join/g));
- text: Your code should not use the <code>replace</code> method.
testString: assert(!code.match(/\.replace/g));
testString: assert(!code.match(/\.?[\s\S]*?replace/g));
- text: <code>sentensify("May-the-force-be-with-you")</code> should return a string.
testString: assert(typeof sentensify("May-the-force-be-with-you") === "string");
- text: <code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.

View File

@ -26,7 +26,7 @@ tests:
- text: <code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.
testString: assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]));
- text: Your code should not use the <code>map</code> method.
testString: assert(!code.match(/\.map/g));
testString: assert(!code.match(/\.?[\s\S]*?map/g));
```

View File

@ -24,7 +24,7 @@ tests:
- text: <code>new_s</code> should equal <code>[23, 65, 5]</code>.
testString: assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]));
- text: Your code should not use the <code>filter</code> method.
testString: assert(!code.match(/\.filter/g));
testString: assert(!code.match(/\.?[\s\S]*?filter/g));
```

View File

@ -32,7 +32,7 @@ tests:
- text: Your code should use the <code>slice</code> method.
testString: assert(code.match(/\.slice/g));
- text: Your code should not use the <code>splice</code> method.
testString: assert(!code.match(/\.splice/g));
testString: assert(!code.match(/\.?[\s\S]*?splice/g));
- text: The <code>inputCities</code> array should not change.
testString: assert(JSON.stringify(inputCities) === JSON.stringify(["Chicago", "Delhi", "Islamabad", "London", "Berlin"]));
- text: <code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.