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

Added support for Regex to determinate a data url #344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sveneberth
Copy link

@sveneberth sveneberth commented Dec 6, 2019

There is currently a problem with SVGs in data-urls.

background-image: url('data:image/svg+xml;utf8,<svg ...> ... </svg>');

After formatting stylefmt return this:

background-image: url('data:image/svg+xml;utf8, <svg ...> ... </svg>');

A space is added after the comma, but this is an incorrect syntax (see RFC2397).

The reason for this incorrect syntax is that stylefmt expects data-urls encoded as base64, but this is still not required by the rfc.

Therefore I removed the base64 part in the regex to allow data ASCII data as well. The data: must be enough as indicator.

Of course we can match the base64 in the regex but this only a test and therefor I reduced it as far as possible.
Alternative would be:

/data:.+\/(.+)(;base64)?,(.*)/

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

Successfully merging this pull request may close these issues.

1 participant