mirror of
https://github.com/KevinMidboe/inline-html.git
synced 2025-10-29 17:40:29 +00:00
Fix bug where assets with a space in their path could not be bundled.
This commit is contained in:
@@ -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
1
test/fixtures/file space.txt
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Test.
|
||||||
@@ -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));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user