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
fix(vscode): attributify value starts with number #1811
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
packages/shared-common/src/index.ts
Outdated
@@ -78,7 +78,7 @@ export function getMatchedPositions(code: string, matched: string[], hasVariantG | |||
|
|||
// attributify values | |||
attributify.forEach(([, name, value]) => { | |||
const regex = new RegExp(`(${e(name)}=)(['"])[^\\2]*?${e(value)}[^\\2]*?\\2`, 'g') | |||
const regex = new RegExp(`(${name}=)(['"])[^\\2]*?${value}[^\\2]*?\\2`, 'g') |
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 e
at least be replaced with escapeRegEx
?
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.
I looked at this function, but I'm sorry, I didn't figure out what it means. Can you explain it in detail?
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.
I looked at this function, but I'm sorry, I didn't figure out what it means. Can you explain it in detail?
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.
I'm sorry the function name was escapeRegExp
. (see search)
export function escapeRegExp(string: string) { |
This is usually done if you are using string from variable while constructing regex, similar to escaping string variable with e()
or the like before using it in html.
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.
@chu121su12 Thanks, you are right, I have replaced e()
with escapeRegExp()
and added tests.
e6359fa
to
5188421
Compare
The string to be tested here is the source code and does not need to be "escaped".