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)); + }); });