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

Allow _ inside url() when using arbitrary values #5853

Merged
merged 2 commits into from
Oct 22, 2021

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Oct 22, 2021

This PR allows you to have _ in url() while using arbitrary values.
Normally we convert _ to spaces . If you want to opt-out of this behaviour, you have to escape the \_ to keep the _.

It does feel a bit awkward to do that for your URLs as well, so this PR allows you to keep _ in URLs without escaping.

@RobinMalfait RobinMalfait changed the title allow for underscores in url() Allow for underscores in url() Oct 22, 2021
Comment on lines +14 to +15
/([^<>"'`\s]*\[\w*\('[^"`\s]*'\)\])/.source, // bg-[url('...'),url('...')]
/([^<>"'`\s]*\[\w*\("[^'`\s]*"\)\])/.source, // bg-[url("..."),url("...")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to simplify all of these regexes, but also a little bit scared of doing it and missing important pieces.

@RobinMalfait RobinMalfait changed the title Allow for underscores in url() Allow _ inside url() when using arbitrary values Oct 22, 2021
@RobinMalfait RobinMalfait merged commit 0ab39c3 into master Oct 22, 2021
@RobinMalfait RobinMalfait deleted the support-unescaped-underscores-in-url branch October 22, 2021 12:43
@jean343
Copy link

jean343 commented Aug 11, 2022

What if we want a space in the URL in the background-image?
For example:

background-image: url("data:image/svg+xml,<svg width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'><rect width='100%' height='100%' fill='none' stroke='%234B7AE7' stroke-dasharray='2,2'/></svg>");

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.

2 participants