mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibRegex: Allocate entries for all capture groups in RegexResult
Not just the seen ones. Fixes #6108.
This commit is contained in:
parent
ef8f8f47ac
commit
76f63c2980
2 changed files with 21 additions and 21 deletions
|
@ -88,3 +88,15 @@ test("Future group backreference, #6039", () => {
|
|||
expect(result[3]).toBe("a");
|
||||
expect(result.index).toBe(1);
|
||||
});
|
||||
|
||||
// #6108
|
||||
test("optionally seen capture group", () => {
|
||||
let rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/;
|
||||
let ua = "mozilla/4.0 (serenityos; x86) libweb+libjs (not khtml, nor gecko) libweb";
|
||||
let res = rmozilla.exec(ua);
|
||||
|
||||
expect(res.length).toBe(3);
|
||||
expect(res[0]).toBe("mozilla");
|
||||
expect(res[1]).toBe("mozilla");
|
||||
expect(res[2]).toBeUndefined();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue