Skip to content

Commit

Permalink
Allow spaces in filenames (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper De Moor authored and devongovett committed Apr 29, 2018
1 parent 19b9fc6 commit fb6912d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ class Asset {
}

const parsed = URL.parse(url);
const resolved = path.resolve(path.dirname(from), parsed.pathname);
const resolved = path.resolve(
path.dirname(from),
decodeURIComponent(parsed.pathname)
);
this.addDependency(
'./' + path.relative(path.dirname(this.name), resolved),
Object.assign({dynamic: true}, opts)
Expand Down
2 changes: 1 addition & 1 deletion src/assets/HTMLAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class HTMLAsset extends Asset {
}

processSingleDependency(path, opts) {
let assetPath = this.addURLDependency(decodeURIComponent(path), opts);
let assetPath = this.addURLDependency(path, opts);
if (!isURL(assetPath)) {
assetPath = urlJoin(this.options.publicURL, assetPath);
}
Expand Down
16 changes: 16 additions & 0 deletions test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,4 +560,20 @@ describe('html', function() {
]
});
});

it('should resolve assets containing spaces', async function() {
let b = await bundle(__dirname + '/integration/resolve-spaces/index.html');

assertBundleTree(b, {
name: 'index.html',
assets: ['index.html'],
childBundles: [
{
type: 'html',
assets: ['other page.html'],
childBundles: []
}
]
});
});
});
6 changes: 6 additions & 0 deletions test/integration/resolve-spaces/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!doctype html>
<html>
<body>
<a href="other page.html">other page</a>
</body>
</html>
6 changes: 6 additions & 0 deletions test/integration/resolve-spaces/other page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!doctype html>
<html>
<body>
<a href="index.html">index</a>
</body>
</html>

0 comments on commit fb6912d

Please sign in to comment.