grunt-ver icon indicating copy to clipboard operation
grunt-ver copied to clipboard

refrences regex doesn't escape '.'

Open stuartf opened this issue 12 years ago • 2 comments

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

stuartf avatar Dec 13 '12 16:12 stuartf

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

noahrc avatar Feb 06 '14 16:02 noahrc

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

jwagner avatar May 05 '15 21:05 jwagner