diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-02-07 13:23:21 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-02-07 13:23:21 +0000 |
| commit | 2428f14e88ff13bcd1ebc2d03eca765ccd1e191c (patch) | |
| tree | 9300e067612de4feafb4913e0e9884ce5a402cd5 /lib/document-xml-reader.js | |
| parent | 68fe7dab8c5f40af8941ca103903044dda319146 (diff) | |
Join paths in zip with forward slashes rather than path.join
Should fix GitHub issue #13
https://github.com/mwilliamson/mammoth.js/issues/13
Diffstat (limited to 'lib/document-xml-reader.js')
| -rw-r--r-- | lib/document-xml-reader.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/document-xml-reader.js b/lib/document-xml-reader.js index 0dcd624..f4701db 100644 --- a/lib/document-xml-reader.js +++ b/lib/document-xml-reader.js @@ -2,7 +2,6 @@ exports.DocumentXmlReader = DocumentXmlReader; var q = require("q"); var _ = require("underscore"); -var path = require("path"); var documents = require("./documents"); var Result = require("./results").Result; @@ -143,7 +142,7 @@ function DocumentXmlReader(relationships, contentTypes, docxFile, numbering) { var results = blips.map(function(blip) { var relationshipId = blip.attributes["r:embed"]; - var imagePath = path.join("word", relationships[relationshipId].target); + var imagePath = joinZipPath("word", relationships[relationshipId].target); var readImage = docxFile.read.bind(docxFile, imagePath); var altText = element.first("wp:docPr").attributes.descr; @@ -188,3 +187,9 @@ function negate(predicate) { return !predicate(value); }; } + +function joinZipPath(first, second) { + // In general, we should check first and second for trailing and leading slashes, + // but in our specific case this seems to be sufficient + return first + "/" + second; +} |
