Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data uri scheme issue #38

Open
shaoner opened this issue Jan 3, 2014 · 2 comments
Open

Data uri scheme issue #38

shaoner opened this issue Jan 3, 2014 · 2 comments

Comments

@shaoner
Copy link

shaoner commented Jan 3, 2014

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:

  • In the HTML splitter regex (but here it seems like a major change, since it affects regex groups position).
  • In the Job _replace method directly by section that skips such uri

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
Copy link

aphexddb commented Feb 5, 2014

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants