Repository navigation
fix(css): keep "//" inside an unquoted url() when minifying - #5450
Merged
Merged
Conversation
The minifier strips "//" to the end of the line as a comment. An unquoted url(https://...) or url(//cdn...) matched it too, so the rest of the declaration and the next one were dropped: background-image: url(https://example.com/a.png); color: red; became "background-image:url(https:color:red". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5450 +/- ##
=======================================
Coverage 80.09% 80.09%
=======================================
Files 159 159
Lines 11128 11129 +1
Branches 2377 2377
=======================================
+ Hits 8913 8914 +1
Misses 2215 2215 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
@breken-ai Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CSS minifier treats
//up to the end of the line as a comment. An unquotedurl()has//in it (https://…or a protocol-relative//cdn…), so the rest of that line and the start of the next declaration get dropped:This also happens when the URL is interpolated, e.g.
url(${imageUrl}). Quotedurl('…')already worked because quoted strings are kept as they are.The fix adds unquoted
url(...)to the tokens the minifier keeps unchanged, next to the quoted strings. Unquoted URLs can't contain quotes, whitespace or), so the pattern stops at the closing parenthesis. It allows whitespace just inside the parentheses.//line comments everywhere else are still removed, and the existing "remove comments" case still passes.The new
preserve unquoted urlcase insrc/helper/css/index.test.tsxfails onmainwith.css-123{background-image:url(https:mask-image:url(color:red}and passes with this change.vp test --project mainpasses (123 files), andtsc -p tsconfig.spec.jsonandvp checkare clean.The author should do the following, if applicable
pnpm run check:fixto format and lint the code🤖 Generated with Claude Code