grunt-cache-bust icon indicating copy to clipboard operation
grunt-cache-bust copied to clipboard

queryString is applied twice in 1.5

Open solitud opened this issue 8 years ago • 3 comments

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.

solitud avatar Jan 07 '17 15:01 solitud

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.

przemos avatar Jan 10 '17 18:01 przemos

I have the same issue

veriKami avatar Jan 16 '17 12:01 veriKami

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.

solitud avatar Jan 16 '17 13:01 solitud