remy / inliner

Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
MIT License
1.1k stars 165 forks source link

error when inlining page with bootstrap #72

Closed dotob closed 8 years ago

dotob commented 8 years ago

hi,

when inlining a page which references bootstrap i always get this error:

λ inliner -v inliner.html
0/1
loading inliner.html
1/1
1/2
processing external css D:\tmp\test\css\bootstrap.css
loading D:\tmp\test\css\bootstrap.css
2/2
compress css
2/8
get image D:\tmp\test\fonts\glyphicons-halflings-regular.eot
loading D:\tmp\test\fonts\glyphicons-halflings-regular.eot
get image D:\tmp\test\fonts\glyphicons-halflings-regular.eot?
loading D:\tmp\test\fonts\glyphicons-halflings-regular.eot?
get image D:\tmp\test\fonts\glyphicons-halflings-regular.woff2
loading D:\tmp\test\fonts\glyphicons-halflings-regular.woff2
get image D:\tmp\test\fonts\glyphicons-halflings-regular.woff
loading D:\tmp\test\fonts\glyphicons-halflings-regular.woff
get image D:\tmp\test\fonts\glyphicons-halflings-regular.ttf
loading D:\tmp\test\fonts\glyphicons-halflings-regular.ttf
get image D:\tmp\test\fonts\glyphicons-halflings-regular.svg
loading D:\tmp\test\fonts\glyphicons-halflings-regular.svg
ENOENT: no such file or directory, open 'D:\tmp\test\fonts\glyphicons-halflings-regular.eot?'

it seems like somehow the ? becomes part of the path.

the used html:

<!DOCTYPE html>
<html>
  <head>
    <title>inliner error</title>
    <link rel="stylesheet" type="text/css" href="bootstrap.css">
  </head>
  <body>
  </body>
</html>

bootstrap is v3.3.5.

if you can point me where to have a look i can propose a pr. or if it is in another lib (eg. cheerio) i can create an issue there.

thanks for your help.

remy commented 8 years ago

So, I think the issue is that the base location is a file, and it's seeing a query string on the font (for cache busting perhaps), but the file read fails because of it: ENOENT: no such file or directory, open 'D:\tmp\test\fonts\glyphicons-halflings-regular.eot?'

I reckon this line just needs to make sure to strip the ? and everything after. You up for the PR? Make sure to read the contributing docs too.