mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:07:46 +00:00
LibRegex+LibJS: Avoid searching for more than one match in JS RegExps
All of JS's regular expression APIs only want a single match, so avoid trying to produce more (which will be discarded anyway).
This commit is contained in:
parent
4c506f91fe
commit
2b028f6faa
5 changed files with 28 additions and 5 deletions
|
@ -25,7 +25,12 @@ class RegExpObject : public Object {
|
|||
public:
|
||||
// JS regexps are all 'global' by default as per our definition, but the "global" flag enables "stateful".
|
||||
// FIXME: Enable 'BrowserExtended' only if in a browser context.
|
||||
static constexpr regex::RegexOptions<ECMAScriptFlags> default_flags { (regex::ECMAScriptFlags)regex::AllFlags::Global | (regex::ECMAScriptFlags)regex::AllFlags::SkipTrimEmptyMatches | regex::ECMAScriptFlags::BrowserExtended };
|
||||
static constexpr regex::RegexOptions<ECMAScriptFlags> default_flags {
|
||||
(regex::ECMAScriptFlags)regex::AllFlags::SingleMatch
|
||||
| (regex::ECMAScriptFlags)regex::AllFlags::Global
|
||||
| (regex::ECMAScriptFlags)regex::AllFlags::SkipTrimEmptyMatches
|
||||
| regex::ECMAScriptFlags::BrowserExtended
|
||||
};
|
||||
|
||||
static RegExpObject* create(GlobalObject&);
|
||||
static RegExpObject* create(GlobalObject&, Regex<ECMA262> regex, String pattern, String flags);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue