fix: strip img query string from local files

When ? was left in url and parsing a local file.

Fixes #72
This commit is contained in:
dotob 2015-11-24 11:24:36 +01:00 committed by Remy Sharp
parent 5b7fc96bc3
commit 82fb14c11f
3 changed files with 12 additions and 1 deletions

View File

@ -7,7 +7,7 @@ var svgo = new SVGO();
var Promise = require('es6-promise').Promise; // jshint ignore:line
function image(url) {
url = url.replace(/#.*$/, '');
url = url.replace(/\??#.*$/, '');
var inliner = this;
this.emit('progress', 'get image ' + url);
return this.get(url, { encoding: 'binary' }).then(function then(res) {

1
test/fixtures/image-url.result.html vendored Normal file
View File

@ -0,0 +1 @@
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline image</title> </head> <body> <img src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs="> </body> </html>

10
test/fixtures/image-url.src.html vendored Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>inline image</title>
</head>
<body>
<img src="1x1.gif?#iefix">
</body>
</html>