-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(minification): properly handle regex character classes #6745
Conversation
} else if (char === '[') { | ||
// Register that we're entering a character class so we don't leave the regex prematurely | ||
isInRegexCharacterClass = true; | ||
} else if (char === ']') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the condition also check that isInRegexCharacterClass is true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't affect the execution but it's definitely a lot more clear :) 👍 done
Two tangential things:
|
sigh 😞, I don't think we'll ever nail all the edge cases. I'm thinking we might want to do a second gut check of, "Hey if it thinks there's a crazy amount of savings when there's like no whitespace in this file, we should just ignore it's result"
😆 hahaha it totally did |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice changes to a weird edge case! But the regex tests are confusing me a bit, they are a little opaque as to what they are testing. I think I need more comments on the case it is testing or clarifications on why my comments are unfounded.
…lighthouse into fix_minification_estimator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, the string escaping was throwing me for a loop, thx for the comments. LGTM
Summary
The minification estimator heuristics weren't accounting for regex character classes properly which meant that it could leave a regex prematurely.
Related Issues/PRs
fixes #6744