Fix bug where assets with a space in their path could not be bundled.

This commit is contained in:
Alexandre Gigliotti
2015-09-11 09:17:10 -07:00
parent f0b9b3cc1e
commit dad1267607
3 changed files with 10 additions and 2 deletions

View File

@@ -16,7 +16,9 @@ var url = require('url');
var clean = function (path) { var clean = function (path) {
path = url.parse(path); path = url.parse(path);
path = _.pick(path, ['protocol', 'host', 'pathname']); path = _.pick(path, ['protocol', 'host', 'pathname']);
return url.format(path); path = url.format(path);
path = decodeURI(path);
return path;
}; };
/** /**
* Convert local url data type paths to datauris. * Convert local url data type paths to datauris.

1
test/fixtures/file space.txt vendored Normal file
View File

@@ -0,0 +1 @@
Test.

View File

@@ -159,5 +159,10 @@ describe('inlineHtml', function () {
var html = (source) => `<style> div { background-image: url('${source}'); }</style>`; var html = (source) => `<style> div { background-image: url('${source}'); }</style>`;
return expect(inline(html(url))).to.eventually.equal(html(uri)); return expect(inline(html(url))).to.eventually.equal(html(uri));
}); });
it('handle assets with a space in their filename', function () {
var filename = path.resolve(__dirname, 'fixtures/file space.txt');
var uri = datauri(filename);
var html = (source) => `<style> div { background-image: url('${source}'); }</style>`;
return expect(inline(html(filename))).to.eventually.equal(html(uri));
});
}); });