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

Update purgecss suggested regex extractor. #18

Merged
merged 2 commits into from
Jul 2, 2018

Conversation

jsnanigans
Copy link

This fixes some issues people have been having. The regex A-z matches some symbols that might be unexpected, I found these but there could be more: `[]-_^
thats why we have changed it to A-Za-z_

@somebody32
Copy link

just tried that and on node 8, I'm getting SyntaxError: Invalid regular expression: /[A-Za-z0-9_-:\/]+/: Range out of order in character class. Were you thinking to escape - and not create a range ie /[A-Za-z0-9_\-:\/]+/g, because I'm not sure that _-: is a valid range

@jsnanigans
Copy link
Author

@somebody32 could you please try this: /[A-Za-z0-9-_:\/]+/ apparently the order of _ and - matters

@adamwathan
Copy link
Member

Hey thanks for the PR! Can you explain the issues you were seeing in more detail? I don't really see an issue with matching those other characters, in fact if anything I would probably want to make the regex even less strict because it's impossible to know what characters someone might be using in the keys in their config file.

@somebody32
Copy link

@adamwathan here is an example why using the previous one was problematic FullHuman/purgecss#75, maybe @jsnanigans has even more of them

@jsnanigans
Copy link
Author

jsnanigans commented Jul 2, 2018

Hey @adamwathan, the main issue is that A-z gives unexpected results and cause quite a few problems to people.

Brought to out attention in this issue the expression A-z includes a lot of characters that are most likely not part of a selector.

A lot of people had problems with string literals - for example in this issue

A lot of the github issues for purgecss have something to do with A-z and by now almost all of those issues stem from the tailwind docs since we updated the default regex extractor some time ago.

Here are a few other issues related to this apart from the one @somebody32 mentioned:
FullHuman/purgecss#56
FullHuman/purgecss#83
FullHuman/purgecss#86

I guess I should have defined the issue better in the PR description :)

@adamwathan
Copy link
Member

Got it, thank you for the history on the issue!

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.

None yet

3 participants