@tomyo and I noticed an issue where running clean-css over our CSS would sometimes mangle image URLs that contain zeros and dots, e.g. assets containing a hash generated by webpack.
For example category_book_medicine@2x.90ab2594.png would get changed to category_book_medicine@2x.9ab2594.png (zero removed).
Environment
- clean-css version -
master / 5.1.5:
- node.js version -
12.21.0:
- operating system:
Pop!_OS 21.04
Configuration options
var CleanCSS = require('clean-css');
new CleanCSS({
level: 1
})
Input CSS
div {
background: image-set(url('foo.10.png') 1x);
}
Actual output CSS
div{background:image-set(url('foo.1.png') 1x)}
Note how 10 was changed to 1. This can also observed with URLs such as 10.10.png, which get's changed to 10.1.png.
Expected output CSS
div{background:image-set(url('foo.10.png') 1x)}
Culprit
We could trace this issue back to the optimizations happening in fraction.js. Disabling just this one optimization returns the expected result. There are a couple other optimizations that return early when their input is considered an URL (startsAsUrl), however in the case of image-set that function returns false.
@tomyo and I noticed an issue where running clean-css over our CSS would sometimes mangle image URLs that contain zeros and dots, e.g. assets containing a hash generated by webpack.
For example
category_book_medicine@2x.90ab2594.pngwould get changed tocategory_book_medicine@2x.9ab2594.png(zero removed).Environment
master / 5.1.5:12.21.0:Pop!_OS 21.04Configuration options
Input CSS
Actual output CSS
Note how
10was changed to1. This can also observed with URLs such as10.10.png, which get's changed to10.1.png.Expected output CSS
Culprit
We could trace this issue back to the optimizations happening in
fraction.js. Disabling just this one optimization returns the expected result. There are a couple other optimizations that return early when their input is considered an URL (startsAsUrl), however in the case ofimage-setthat function returns false.