From dad12676072153d074253c53540908858c973e3a Mon Sep 17 00:00:00 2001 From: Alexandre Gigliotti Date: Fri, 11 Sep 2015 09:17:10 -0700 Subject: [PATCH] Fix bug where assets with a space in their path could not be bundled. --- lib/inline-css-url.js | 4 +++- test/fixtures/file space.txt | 1 + test/index.js | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/file space.txt diff --git a/lib/inline-css-url.js b/lib/inline-css-url.js index b7e262b..6351e9f 100644 --- a/lib/inline-css-url.js +++ b/lib/inline-css-url.js @@ -16,7 +16,9 @@ var url = require('url'); var clean = function (path) { path = url.parse(path); 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. diff --git a/test/fixtures/file space.txt b/test/fixtures/file space.txt new file mode 100644 index 0000000..90b67dd --- /dev/null +++ b/test/fixtures/file space.txt @@ -0,0 +1 @@ +Test. diff --git a/test/index.js b/test/index.js index 5ed8472..1de3f9d 100644 --- a/test/index.js +++ b/test/index.js @@ -159,5 +159,10 @@ describe('inlineHtml', function () { var html = (source) => ``; 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) => ``; + return expect(inline(html(filename))).to.eventually.equal(html(uri)); + }); });