diff --git a/lib/utils.js b/lib/utils.js index 2c543360d..98e05036c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -12,6 +12,7 @@ var path = require('path'); var S = require('string'); function uriToFilename(uri, base) { + uri = decodeURIComponent(uri) var filename = path.join(base, uri); // Make sure filename ends with '/' if filename exists and is a directory. // TODO this sync operation can be avoided and can be left diff --git a/test/utils.js b/test/utils.js index 9c4fac167..9319cb6f3 100644 --- a/test/utils.js +++ b/test/utils.js @@ -20,5 +20,9 @@ describe('Utility functions', function() { it('should return empty as relative path for undefined path', function() { assert.equal(utils.pathBasename(undefined), ''); }); + + it('should properly decode a uri', function() { + assert.equal(utils.uriToFilename('uri%20', 'base/'), 'base/uri ') + }); }); }); \ No newline at end of file