Respect <base> element when parsing url() in CSS
Say you have the following HTML in index.html
, in a folder hosted by python -m SimpleHTTPServer 8000 .
(or any web server, or even file:///
):
<html>
<head>
<base href="/assets/">
<style>
@font-face {
font-family: 'inknut_antiquaregular';
src: url('./InknutAntiqua-Regular-webfont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
h1 {
font-family: 'inknut_antiquaregular';
}
</style>
</head>
<body>
<h1>foo</h1>
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
</body>
</html>
Then you have the .woff
file in a subfolder called assets
.
Paged.js 0.1.30 does not respect the <base>
tag.
Expected behavior
The CSS paged.js injects into the <head>
should not be rewritten at all, or at least rewritten to something that resolves, like:
url('./assets/InknutAntiqua-Regular-webfont.woff')
Actual behavior
The CSS is rewritten to:
url('http://localhost:8000/InknutAntiqua-Regular-webfont.woff')
which of course gives a 404.
P.S. Stumbled upon this in https://github.com/mb21/panwriter/issues/6
Repro: fonttest.zip