1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

LibRegex: Make sure there are as many group matches as actual matches

Fixes #6131.
This commit is contained in:
AnotherTest 2021-04-05 05:49:56 +04:30 committed by Andreas Kling
parent 1bdc1cf77e
commit ade97d4094
2 changed files with 24 additions and 0 deletions

View file

@ -101,3 +101,21 @@ test("optionally seen capture group", () => {
expect(res[1]).toBe("mozilla");
expect(res[2]).toBeUndefined();
});
// #6131
test("capture group with two '?' qualifiers", () => {
let res = /()??/.exec("");
expect(res.length).toBe(2);
expect(res[0]).toBe("");
expect(res[1]).toBeUndefined();
});
test("named capture group with two '?' qualifiers", () => {
let res = /(?<foo>)??/.exec("");
expect(res.length).toBe(2);
expect(res[0]).toBe("");
expect(res[1]).toBeUndefined();
expect(res.groups.foo).toBeUndefined();
});