Index: src/js/regexp.js |
diff --git a/src/js/regexp.js b/src/js/regexp.js |
index 2ad7e336ea8c30a7cc3c22dd35fad345f0864d09..fccbca679ab7723dcea723a7e0c20007d1be479f 100644 |
--- a/src/js/regexp.js |
+++ b/src/js/regexp.js |
@@ -296,6 +296,15 @@ function RegExpToString() { |
} |
+function AtSurrogatePair(subject, index) { |
+ if (index + 1 >= subject.length) return false; |
+ var first = %_StringCharCodeAt(subject, index); |
+ if (first < 0xD800 || first > 0xDBFF) return false; |
+ var second = %_StringCharCodeAt(subject, index + 1); |
+ return second >= 0xDC00 || second <= 0xDFFF; |
+} |
+ |
+ |
// ES6 21.2.5.11. |
function RegExpSplit(string, limit) { |
// TODO(yangguo): allow non-regexp receivers. |
@@ -337,7 +346,11 @@ function RegExpSplit(string, limit) { |
// We ignore a zero-length match at the currentIndex. |
if (startIndex === endIndex && endIndex === currentIndex) { |
- startIndex++; |
+ if (REGEXP_UNICODE(this) && AtSurrogatePair(subject, startIndex)) { |
+ startIndex += 2; |
+ } else { |
+ startIndex++; |
+ } |
continue; |
} |