diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-01-23 20:42:02 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-01-23 20:42:02 +0000 |
| commit | 15f4381cf54901895836551a30f66c0cee974a0c (patch) | |
| tree | 6a02b9c3d7be8adbc5315b7eaa29eb217a9d1418 /lib/docx | |
| parent | e81f83906d26ace7c38b0b7b24e0d5f98da35172 (diff) | |
Move target URI handling out of zipfile module
Diffstat (limited to 'lib/docx')
| -rw-r--r-- | lib/docx/body-reader.js | 2 | ||||
| -rw-r--r-- | lib/docx/uris.js | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index e683168..529d6f2 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -5,7 +5,7 @@ var _ = require("underscore"); var documents = require("../documents"); var Result = require("../results").Result; var warning = require("../results").warning; -var uriToZipEntryName = require("../zipfile").uriToZipEntryName; +var uriToZipEntryName = require("./uris").uriToZipEntryName; function BodyReader(options) { diff --git a/lib/docx/uris.js b/lib/docx/uris.js new file mode 100644 index 0000000..0179e5b --- /dev/null +++ b/lib/docx/uris.js @@ -0,0 +1,11 @@ +exports.uriToZipEntryName = uriToZipEntryName; + +function uriToZipEntryName(base, uri) { + if (uri.charAt(0) === "/") { + return uri.substr(1); + } else { + // In general, we should check first and second for trailing and leading slashes, + // but in our specific case this seems to be sufficient + return base + "/" + uri; + } +} |
