-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
The URL_RE doesn't work if the font URL contains a ")" close paren character #296
Comments
MDN has some details about the flexible varaitions that the CSS Based on the description and some googling, I'm not sure that this formal spec can be succinctly represented by a single regex. Nearly all answers and examples for this specific parsing task that I can find use a naive variation of what this library is already doing. |
I’ve played with bringing in lightningcss and using a url visitor to aggregate all valid urls in a font face rule instead of the URL_RE behavior I believe it works well, except, it will behave differently for the existing test case of invalid syntax on the family name when the quotes aren’t closed properly. I’ll look to open a PR and possibly hide it behind a feature flag |
Using lightningcss to parse the @font-face rules definitely works, however, it would be in a stricter, more standards compliant way. This means potential behavioral differences to how this library currently behaves, which is using some relatively naive regexes that make it usually do the right thing even when it's presented with relatively or very invalid Happy to pursue this avenue if there's interest, otherwise, maybe a |
This may be a good regex to use for the
Seems to work reasonably well and accounts for most of the ways a valid CSS Works with the following input URLs
|
🐛 The bug
There are some packages, for example, the inter-ui NPM package (which is recommended by the official inter GH readme for NPM) which, very unfortunately, have parens in some of the folder names.
For example from the inter-ui package the fonts are under folders with parens in their names.
Example font file:
inter-ui/Inter (web)/Inter-Regular.woff2
The
URL_RE
that fontaine is using is defined asSo no matter what it breaks with these URLs.
The problem is that source URL would get regex'd out as
inter-ui/Inter (web
and then the next check is to see if the source ends with one of the supported extensions (and since the regex mangled the URL, the extension was lost).🛠️ To reproduce
https://stackblitz.com/edit/github-hdufeg?file=index.css
🌈 Expected behaviour
Parsing of the source url should support any valid URL characters
ℹ️ Additional context
No response
The text was updated successfully, but these errors were encountered: