minifier icon indicating copy to clipboard operation
minifier copied to clipboard

Quotation marks get removed from @font-face src urls causing problems with spaces in font names

Open abhijitparida opened this issue 7 years ago • 6 comments

@font-face {
    font-family: 'Nexa Light';
    src: url('font/Nexa Light.otf');
}

becomes

@font-face{font-family:'Nexa Light';src:url(font/Nexa Light.otf)}

It should be

@font-face{font-family:'Nexa Light';src:url('font/Nexa Light.otf')}
                                            ^^^^^^^^^^^^^^^^^^^^^

abhijitparida avatar Nov 01 '17 11:11 abhijitparida

Interesting. You can work around the problem by replacing the space with %20, making your code @font-face{font-family:'Nexa Light';src:url(font/Nexa%20Light.otf)

fizker avatar Nov 09 '17 11:11 fizker

I have the same problem, quotation marks get removed from css urls, when i change the output folder of the minified file, the paths change with it, so they can't be found at all:

.form {
  background: #59cbcc url('../images/loginBG.jpg');
}

becomes

.form{background:#59cbcc url(../../../../../images/loginBG.jpg)}

mik3009 avatar Nov 14 '17 12:11 mik3009

@mik3009 That is not at all the same problem. Your problem is that you manually copy the image, but use the tool to copy the CSS. The tool keeps the relative path the same during the transformation, but you want it to be massively different post-transformation

fizker avatar Nov 14 '17 13:11 fizker

Hi fizker, thanks for your reply. It still removes the quotations marks though, and why are quoted strings changed? I don't see this behaviour in js files either only in css, eventhough they are copied the same way.

mik3009 avatar Nov 14 '17 13:11 mik3009

See https://github.com/fizker/minifier#css-url-rewrites, which is slightly wrong because quotations are removed to save 2 bytes per URL (which breaks urls containing spaces)

I am pretty sure that strings in JS are also being changed, but probably just to normalise between ' and ". This behaviour ultimately depends on how uglify-js stringifies its AST

fizker avatar Nov 14 '17 14:11 fizker

Ha thanks again for your swift reply, I'll read up on the rewrites.

edit: I changed the paths, so that'll be fine now, thanks for that.

mik3009 avatar Nov 14 '17 14:11 mik3009