Skip to content

Commit

Permalink
Fix optimizeByLowSurrogates bug (#41)
Browse files Browse the repository at this point in the history
mathiasbynens/regexpu#72

Co-authored-by: Mathias Bynens <mathias@qiwi.be>
  • Loading branch information
Yaffle and mathiasbynens committed Nov 1, 2020
1 parent 4aee39d commit 66ae9f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion regenerate.js
Expand Up @@ -869,7 +869,8 @@
var otherLowSurrogateEnd = otherLowSurrogates[1];
if (
lowSurrogateStart == otherLowSurrogateStart &&
lowSurrogateEnd == otherLowSurrogateEnd
lowSurrogateEnd == otherLowSurrogateEnd &&
otherLowSurrogates.length === 2
) {
// Add the code points in the other item to this one.
if (dataIsSingleton(otherMapping[0])) {
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.js
Expand Up @@ -818,6 +818,11 @@
[42, 43],
'each Regenerate instance `set` stores its data in `set.data` for plugins to use'
);
equal(
regenerate().add(0x11450, 0x11C50, 0x11C52).toString(),
'\\uD805\\uDC50|\\uD807[\\uDC50\\uDC52]',
'a test for a bug in `optimizeByLowSurrogates`'
);
});
test('acid tests', function() {
// Based on the output for https://gist.github.com/mathiasbynens/6334847
Expand Down

0 comments on commit 66ae9f3

Please sign in to comment.