Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: src/harmony-string.js

Issue 120683002: Make `String.prototype.{starts,ends}With` throw when passing a regular expression (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/messages.js » ('j') | test/mjsunit/harmony/string-endswith.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/harmony-string.js
diff --git a/src/harmony-string.js b/src/harmony-string.js
index 8e4b9a462646470a4522c894547d2b0d81da1b6e..0b553720816a8cd86ab9deba3212c843d10ca6a1 100644
--- a/src/harmony-string.js
+++ b/src/harmony-string.js
@@ -64,6 +64,12 @@ function StringStartsWith(searchString /* position */) { // length == 1
}
var s = TO_STRING_INLINE(this);
+
+ if (IS_REGEXP(searchString)) {
+ throw MakeTypeError("first_argument_not_regexp",
+ ["String.prototype.startsWith"]);
+ }
+
var ss = TO_STRING_INLINE(searchString);
var pos = 0;
if (%_ArgumentsLength() > 1) {
@@ -90,6 +96,12 @@ function StringEndsWith(searchString /* position */) { // length == 1
}
var s = TO_STRING_INLINE(this);
+
+ if (IS_REGEXP(searchString)) {
+ throw MakeTypeError("first_argument_not_regexp",
+ ["String.prototype.endsWith"]);
+ }
+
var ss = TO_STRING_INLINE(searchString);
var s_len = s.length;
var pos = s_len;
« no previous file with comments | « no previous file | src/messages.js » ('j') | test/mjsunit/harmony/string-endswith.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698