mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
LibJS: Make invalid RegExp flags a SyntaxError at parse time
This patch changes the validation of RegExp flags (checking for invalid and duplicate values) from a SyntaxError at runtime to a SyntaxError at parse time - it's not something that's supposed to be catchable. As a nice side effect, this simplifies the RegExpObject constructor a bit, as it can no longer throw an exception and doesn't have to validate the flags itself.
This commit is contained in:
parent
c93c2dc72c
commit
60064e2049
4 changed files with 22 additions and 33 deletions
|
@ -49,10 +49,10 @@ test("flag and options", () => {
|
|||
expect(re.unicode).toBe(false);
|
||||
|
||||
expect(() => {
|
||||
/foo/gg;
|
||||
Function("/foo/gg");
|
||||
}).toThrowWithMessage(SyntaxError, "Repeated RegExp flag 'g'");
|
||||
|
||||
expect(() => {
|
||||
/foo/x;
|
||||
Function("/foo/x");
|
||||
}).toThrowWithMessage(SyntaxError, "Invalid RegExp flag 'x'");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue