tactivos / grunt-cdn

79 stars 53 forks source link

Data uri scheme issue #38

Open shaoner opened 10 years ago

shaoner commented 10 years ago

Hi,

It seems that uri like: <img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA .... "> are not currently supported, it just replaces "data:image" with the cdn url because it is not detected in the splitter and because of the url.parse line in _replace method . Note that this also stands for link, script, url, etc. I would have opened a pull request, but I'm not sure how you want to handle such a case:

For now I've been using ignorePath to handle that, and this works:

cdn: {
  options: {
    cdn: 'http://mycdn',
    ignorePath: /data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]/i
  }
}

Not completely sure the regex handles all cases. Anyway, let me know if you want me to open a pull request.

aphexddb commented 10 years ago

This is a showstopper for me. I have this is my css:

background-image: url('data:image/svg+xml;base64,PD94bWwgdm ...

and it gets rewritten:

background-image: url('//cdn.example.com/svg+xml;base64,PD94bWwgdm ...
johnnyhalife commented 10 years ago

open a pull request and I'll merge it and publish to NPM