Skip to content

refrences regex doesn't escape '.'#2

Open
stuartf wants to merge 1 commit into
chrisdanford:masterfrom
stuartf:master
Open

refrences regex doesn't escape '.'#2
stuartf wants to merge 1 commit into
chrisdanford:masterfrom
stuartf:master

Conversation

@stuartf

@stuartf stuartf commented Dec 13, 2012

Copy link
Copy Markdown

When doing the substitutions in references the regex looks like:

regex = new RegExp('\\b' + to.basename + '\\b', 'g');

So if you have a basename like foo.js and a path like /foo/js/bar.js the foo/js will be replaced when it shouldn't. Before building that regex it would be safer to escape all the regex special characters from to.basename, someone on StackOverflow has even already written a regex to do that: http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript/3561711#3561711

@noahrc

noahrc commented Feb 6, 2014

Copy link
Copy Markdown

+1 this fixed the problems I was having with the regex

@jwagner

jwagner commented May 5, 2015

Copy link
Copy Markdown

Ran into this issue too, would be cool if this could be merged.

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

Successfully merging this pull request may close these issues.

3 participants