aboutsummaryrefslogtreecommitdiff
path: root/lib/content-types-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-03-18 14:15:33 +0000
committerMichael Williamson <mike@zwobble.org>2014-03-18 14:15:33 +0000
commit45f302766a3a5ca99338fd8e5fef07dec42c0e56 (patch)
treee5081b43310e6c3698c08ab021e0d61d0a84d09c /lib/content-types-reader.js
parentdca50ccd84f91a7db2a41a59e15b3ed95b2c3f46 (diff)
Move modules for docx reading into separate directory
Diffstat (limited to 'lib/content-types-reader.js')
-rw-r--r--lib/content-types-reader.js50
1 files changed, 0 insertions, 50 deletions
diff --git a/lib/content-types-reader.js b/lib/content-types-reader.js
deleted file mode 100644
index 0a74eb9..0000000
--- a/lib/content-types-reader.js
+++ /dev/null
@@ -1,50 +0,0 @@
-var readXmlFromZipFile = require("./office-xml-reader").readXmlFromZipFile;
-
-exports.readContentTypesFromZipFile = readContentTypesFromZipFile;
-exports.readContentTypesFromXml = readContentTypesFromXml;
-
-
-function readContentTypesFromZipFile(file) {
- return readXmlFromZipFile(file, "[Content_Types].xml")
- .then(function(xml) {
- return xml ? readContentTypesFromXml(xml) : defaultContentTypes;
- });
-}
-
-function readContentTypesFromXml(xml) {
- var extensionDefaults = {};
- var overrides = {};
-
- xml.root.children.forEach(function(child) {
- if (child.name === "content-types:Default") {
- extensionDefaults[child.attributes.Extension] = child.attributes.ContentType;
- }
- if (child.name === "content-types:Override") {
- var name = child.attributes.PartName;
- if (name.charAt(0) === "/") {
- name = name.substring(1);
- }
- overrides[name] = child.attributes.ContentType;
- }
- });
-
- return {
- findContentType: function(path) {
- var overrideContentType = overrides[path];
- if (overrideContentType) {
- return overrideContentType;
- } else {
- var pathParts = path.split(".");
- var extension = pathParts[pathParts.length - 1];
- return extensionDefaults[extension];
- }
- }
- }
-}
-
-
-var defaultContentTypes = {
- findContentType: function(path) {
- return null;
- }
-};