Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

Handle spaces in paths in fs-resolver #124

Merged
merged 1 commit into from
Jun 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions hydrolysis.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion lib/loader/fs-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ FSResolver.prototype = {
accept: function(uri, deferred) {
var parsed = url.parse(uri);
var host = this.config.host;
var base = this.config.basePath;
var base = this.config.basePath && decodeURIComponent(this.config.basePath);
var root = this.config.root && path.normalize(this.config.root);
var redirect = this.config.redirect;

Expand All @@ -79,6 +79,9 @@ FSResolver.prototype = {
}

if (local) {
// un-escape HTML escapes
local = decodeURIComponent(local);

if (base) {
local = path.relative(base, local);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"watch": "latest"
},
"dependencies": {
"dom5": "^1.0.3",
"dom5": "^1.1.0",
"es6-promise": "^2.1.0",
"espree": "^2.0.1",
"estraverse": "^3.1.0",
Expand Down
1 change: 1 addition & 0 deletions test/static/spaces in request.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Spaces!
21 changes: 21 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,27 @@ suite('Loader', function() {
assert.equal(content.trim(), 'Hello!');
}).then(done, done);
});

test('Spaces in Filepath', function(done) {
var fs = new fsResolver({
root: path.join(__dirname, '..')
});
l.addResolver(fs);
l.request('/test/static/spaces%20in%20request.txt').then(function(content) {
assert.equal(content.trim(), 'Spaces!');
}).then(done, done);
});

test('Spaces in Filepath', function(done) {
var fs = new fsResolver({
root: path.join(__dirname, '..'),
basePath: '/space%20in%20basePath'
});
l.addResolver(fs);
l.request('/space%20in%20basePath/test/static/xhr-text.txt').then(function(content) {
assert.equal(content.trim(), 'Hello!');
}).then(done, done);
});
});

suite('Noop Resolver', function() {
Expand Down