mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
LibJS: Behave like major engines when substituting missing capture group
When a substitution refers to a 2-digit capture group that doesn't exist we need to check if the first digit refers to an existing capture group. In other words, '$10' should be treated as capture group #1, followed by the literal '0' if 1 is a valid capture group but 10 is not. This makes the Dromaeo "dom-query" subtest run to completion.
This commit is contained in:
parent
b5ed86ab68
commit
9d6f00d918
2 changed files with 15 additions and 0 deletions
|
@ -248,3 +248,9 @@ test("UTF-16", () => {
|
|||
|
||||
expect("".replace("", "😀")).toBe("😀");
|
||||
});
|
||||
|
||||
test("substitution with capture group", () => {
|
||||
expect("A".replace(/(A)/, "$1")).toBe("A");
|
||||
expect("A".replace(/(A)/, "$10")).toBe("A0");
|
||||
expect("A".replace(/(A)/, "$2")).toBe("$2");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue