mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Track whether a pattern can match empty and only skip interior surrogate positions when the matcher must consume input. This keeps the unicode candidate scan fast for consuming searches without dropping valid zero-width matches such as /\B/ and /(?!...)/ between a surrogate pair's two code units. Add runtime coverage for both global lastIndex searches and plain exec() searches on zero-width unicode patterns.
16 lines
485 B
JavaScript
16 lines
485 B
JavaScript
test("unicode zero-width patterns can match at surrogate interior positions", () => {
|
|
let global_matcher = /\B/gu;
|
|
global_matcher.lastIndex = 2;
|
|
|
|
let match = global_matcher.exec("A😀");
|
|
expect(match).not.toBeNull();
|
|
expect(match[0]).toBe("");
|
|
expect(match.index).toBe(2);
|
|
expect(global_matcher.lastIndex).toBe(2);
|
|
|
|
match = /(?!😀)/u.exec("😀");
|
|
expect(match).not.toBeNull();
|
|
expect(match[0]).toBe("");
|
|
expect(match.index).toBe(1);
|
|
});
|