aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-09-06 17:36:53 +0100
committerMichael Williamson <mike@zwobble.org>2015-09-06 17:36:53 +0100
commit854682f7fcc4c68034b1174f461558840f39a7bf (patch)
treea9600215f9910097d350c8703bfae220937759d9
parentcccaa16098484a7d9df26c18c0b6aa5b9defbeb5 (diff)
Decode URIs
-rw-r--r--lib/docx/files.js2
-rw-r--r--tests/docx/files.tests.js4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/docx/files.js b/lib/docx/files.js
index 6e6f797..e25d9cc 100644
--- a/lib/docx/files.js
+++ b/lib/docx/files.js
@@ -23,7 +23,7 @@ var readFile = promises.promisify(fs.readFile.bind(fs));
function uriToPath(uri) {
var fileUriPrefix = "file:///";
if (startsWith(uri, fileUriPrefix)) {
- return uri.slice(fileUriPrefix.length - 1);
+ return decodeURIComponent(uri.slice(fileUriPrefix.length - 1));
} else {
throw new Error("Could not convert URI to path: " + uri);
}
diff --git a/tests/docx/files.tests.js b/tests/docx/files.tests.js
index fecc6eb..a21bc93 100644
--- a/tests/docx/files.tests.js
+++ b/tests/docx/files.tests.js
@@ -29,4 +29,8 @@ describe("uriToPath", function() {
test("leading slash is retained on non-Windows file URIs", function() {
assert.equal(uriToPath("file:///a/b/c"), "/a/b/c");
});
+
+ test("URI is unquoted", function() {
+ assert.equal(uriToPath("file:///a%20b"), "/a b");
+ });
});