Skip to content

Error in some path replacements  #3

@jaysalvat

Description

@jaysalvat

First hello and thanks a lot :)

In some cases the replacements are wrong.
I have a file name logo.svg and in my CSS I have a class like this:

.header-logo svg {

After replacement it becomes:

.header-logo.5207648e7fbe6e1d.svg {

It's because of the . in the file name and the Regex at this line.
https://github.com/jhuesos/gulp-cachebust/blob/master/index.js#L123
. matches the space.

The filename should be escaped for RegExp.

My quick and dirty patch.

original = original.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");

(from StackOverflow: https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex)

Sorry no time for a proper clean pull request. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions