| Index: src/string.js
|
| diff --git a/src/string.js b/src/string.js
|
| index cb82c166346fc7ba5491a1e9e5d28e0e9b5a5108..c73ef0697c3334a8bb0a11e741e682b6fb4d9c33 100644
|
| --- a/src/string.js
|
| +++ b/src/string.js
|
| @@ -882,6 +882,37 @@ function StringFromCharCode(code) {
|
| }
|
|
|
|
|
| +// ES6 draft 07-15-13, section 15.5.3.22
|
| +function StringStartsWith(searchString /* position */) { // length == 1
|
| + if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
|
| + throw MakeTypeError("called_on_null_or_undefined",
|
| + ["String.prototype.startsWith"]);
|
| + }
|
| +
|
| + var s = TO_STRING_INLINE(this);
|
| + var s_len = s.length;
|
| + var ss = TO_STRING_INLINE(searchString);
|
| + var ss_len = ss.length;
|
| +
|
| + if (ss_len > 0) {
|
| + var pos = 0;
|
| + if (%_ArgumentsLength() > 1) {
|
| + pos = %_Arguments(1); // position
|
| + pos = TO_INTEGER(pos);
|
| + }
|
| +
|
| + var start = $Math.min($Math.max(pos, 0), s_len);
|
| + if (ss_len + start > s_len) {
|
| + return false;
|
| + }
|
| +
|
| + return %StringIndexOf(s, ss, start) === start;
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +
|
| // Helper function for very basic XSS protection.
|
| function HtmlEscape(str) {
|
| return TO_STRING_INLINE(str).replace(/</g, "<")
|
| @@ -1010,7 +1041,8 @@ function SetUpString() {
|
| "small", StringSmall,
|
| "strike", StringStrike,
|
| "sub", StringSub,
|
| - "sup", StringSup
|
| + "sup", StringSup,
|
| + "startsWith", StringStartsWith
|
| ));
|
| }
|
|
|
|
|