Skip to content
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

Problem in RegEx cause some mixing between caassets #7

Open
niros1 opened this issue Nov 28, 2017 · 0 comments
Open

Problem in RegEx cause some mixing between caassets #7

niros1 opened this issue Nov 28, 2017 · 0 comments

Comments

@niros1
Copy link

niros1 commented Nov 28, 2017

Problem:
Hashed svg with the following name man.1234566.svg (original file was man.svg) will match icon with this name "cdicon-man.svg" and change it to "cdicon-man.1234566.svg"
Example string: "is.cdicon_man_href=u.a.urls.resources.SVGs+"cdicon-man.svg#cdicon-man",this.authenti"
The reason is the \b does not cover all word boundaries in case of file name ("-" is legible character in file name).

This is the problematic line in the code:
contents = contents.replace(new RegExp('\\b' + original + '(?!\\.)\\b', 'g'), cachebusted);

Suggested regex: [^a-zA-Z0-9_-]man.svg(?!.)\b
Other characters except from "-" can be added
New code line:
contents = contents.replace(new RegExp('[^a-zA-Z0-9_-]' + original + '(?!\.)\b', 'g'), cachebusted);

be glad to get feedback on that, as well I will open a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant