aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-09-06 11:10:23 +0100
committerMichael Williamson <mike@zwobble.org>2015-09-06 11:10:23 +0100
commite1344467f2301c122f8ce00b2ddf29db92bc90d2 (patch)
tree012c7dbf82e2200fb6051ed5330b7349e6d21058
parentd4a14afabc917a06cd3ac67ccb03c69bf0299821 (diff)
Make fallback content types case-insensitive
-rw-r--r--lib/docx/content-types-reader.js2
-rw-r--r--tests/docx/content-types-reader.tests.js7
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/docx/content-types-reader.js b/lib/docx/content-types-reader.js
index fc95771..5364b87 100644
--- a/lib/docx/content-types-reader.js
+++ b/lib/docx/content-types-reader.js
@@ -44,7 +44,7 @@ function contentTypes(overrides, extensionDefaults) {
if (extensionDefaults.hasOwnProperty(extension)) {
return extensionDefaults[extension];
} else {
- var fallback = fallbackContentTypes[extension];
+ var fallback = fallbackContentTypes[extension.toLowerCase()];
if (fallback) {
return "image/" + fallback;
} else {
diff --git a/tests/docx/content-types-reader.tests.js b/tests/docx/content-types-reader.tests.js
index 3390e43..a223d09 100644
--- a/tests/docx/content-types-reader.tests.js
+++ b/tests/docx/content-types-reader.tests.js
@@ -37,4 +37,11 @@ describe('readContentTypesFromXml', function() {
assert.equal(contentTypes.findContentType("word/media/hat.tif"), "image/tiff");
assert.equal(contentTypes.findContentType("word/media/hat.tiff"), "image/tiff");
});
+
+ test('fallback content types are case insensitive on extension', function() {
+ var contentTypes = readContentTypesFromXml({
+ root: new XmlElement("content-types:Types", {}, [])
+ });
+ assert.equal(contentTypes.findContentType("word/media/hat.PnG"), "image/png");
+ });
});