grunt-cache-bust
grunt-cache-bust copied to clipboard
queryString is applied twice in 1.5
I am using grunt-cache-bust with the queryString parameter.
In 1.4 everything seams to be working but in 1.5 the query string is attached everytime the script is called.
E.G. instead of
<link rel="stylesheet" type="text/css" href="/css/mg.min.css?5b4d6a0ad38a6627" />
I am getting
<link rel="stylesheet" type="text/css" href="/css/mg.min.css?5b4d6a0ad38a6627?5b4d6a0ad38a6627?5b4d6a0ad38a6627" />
cacheBust: {
options: {
assets: ['js/*.min.js', 'css/*.min.css'],
baseDir: './app/webroot/',
queryString: true
},
dist: {
expand: true,
cwd: 'app/View/Layouts/',
src: ['*.ctp']
}
},
Edit: no, it does not work in 1.4 either.
Yes, the offending line is:
replaceEnclosedBy = replaceEnclosedBy.concat(replaceEnclosedBy.map(function(reb) { return [reb[0], '?']; }));
As when it comes to split:
_.each(replaceEnclosedBy, function(reb) { console.log(reb[0], original, reb[1]); markup = markup.split(reb[0] + original + reb[1]).join(reb[0] + hashed + reb[1]); });
It actually replaces the asset twice. First when finding asset within "" -> "/css/mg.min.css" , second when finding asset within " ? which results from previous substition: "/css/mg.min.css**?**5b4d6a0ad38a6627" I am not entirely sure about the value of cache busting assets that already have query params attached to it. I would roll that back unless somebody has a compelling case.
I have the same issue
If you don't have to use grunt-cache-bust for several reasons just try an other project. E.g. grunt-cache-breaker is easy and works without issues.