mirror of
https://github.com/remy/inliner.git
synced 2024-09-11 17:25:30 +03:00
fix: spaces in file names
Fixes inlining local files with spaces in names. Fixes #148.
This commit is contained in:
parent
5786954e07
commit
c3cbdf0346
@ -31,7 +31,13 @@ module.exports = function get(url, options) {
|
|||||||
|
|
||||||
if (this.isFile && url.indexOf('http') !== 0) {
|
if (this.isFile && url.indexOf('http') !== 0) {
|
||||||
debug('inliner.get file: %s', url);
|
debug('inliner.get file: %s', url);
|
||||||
cache[url] = fs.readFile(url).then(function read(body) {
|
cache[url] = fs.readFile(url).catch(function (error) {
|
||||||
|
if (error.code === 'ENOENT' || error.code === 'ENAMETOOLONG') {
|
||||||
|
debug(error.code + ': ' + base + ', trying decodeURI');
|
||||||
|
return fs.readFile(decodeURI(url));
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}).then(function read(body) {
|
||||||
return {
|
return {
|
||||||
body: body,
|
body: body,
|
||||||
headers: {
|
headers: {
|
||||||
|
4
test/fixtures/spaces in names.css
vendored
Normal file
4
test/fixtures/spaces in names.css
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
body {
|
||||||
|
background-color: #222;
|
||||||
|
color: wheat;
|
||||||
|
}
|
1
test/fixtures/spaces in names.js
vendored
Normal file
1
test/fixtures/spaces in names.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log("Hi");
|
1
test/fixtures/spaces in names.result.html
vendored
Normal file
1
test/fixtures/spaces in names.result.html
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<!DOCTYPE html> <html> <head> <title>Spaces in file names test</title> <meta charset="UTF-8"> <style>body{ background-color:#222;color:wheat;}</style> <script type="text/javascript">console.log("Hi");</script> </head> <body> <div>Some content</div> </body> </html>
|
12
test/fixtures/spaces in names.src.html
vendored
Normal file
12
test/fixtures/spaces in names.src.html
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Spaces in file names test</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="stylesheet" href="spaces%20in%20names.css" />
|
||||||
|
<script type="text/javascript" src="spaces%20in%20names.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Some content</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user