[Pkg-javascript-commits] [node-mime] 03/13: Imported Upstream version 1.2.11
Jérémy Lal
kapouer at moszumanska.debian.org
Sat Jun 14 14:10:56 UTC 2014
This is an automated email from the git hooks/post-receive script.
kapouer pushed a commit to branch master
in repository node-mime.
commit 5626df1d01183bf2e4b16095def8b62d05e55c45
Author: Jérémy Lal <kapouer at melix.org>
Date: Sat Jun 14 15:22:49 2014 +0200
Imported Upstream version 1.2.11
---
mime.js | 2 +-
package.json | 2 +-
test.js | 24 ++++++++++++------------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/mime.js b/mime.js
index 8a7eb09..48be0c5 100644
--- a/mime.js
+++ b/mime.js
@@ -69,7 +69,7 @@ Mime.prototype.load = function(file) {
* Lookup a mime type based on extension
*/
Mime.prototype.lookup = function(path, fallback) {
- var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
+ var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
return this.types[ext] || fallback || this.default_type;
};
diff --git a/package.json b/package.json
index 0f82f6b..9e95575 100644
--- a/package.json
+++ b/package.json
@@ -18,5 +18,5 @@
"main": "mime.js",
"name": "mime",
"repository": {"url": "https://github.com/broofa/node-mime", "type": "git"},
- "version": "1.2.10"
+ "version": "1.2.11"
}
diff --git a/test.js b/test.js
index 27df440..2cda1c7 100644
--- a/test.js
+++ b/test.js
@@ -18,16 +18,16 @@ console.log(Object.keys(mime.types).length + ' extensions\n');
// Test mime lookups
//
-eq('text/plain', mime.lookup('text.txt'));
-eq('text/plain', mime.lookup('.text.txt'));
-eq('text/plain', mime.lookup('.txt'));
-eq('text/plain', mime.lookup('txt'));
-eq('application/octet-stream', mime.lookup('text.nope'));
-eq('fallback', mime.lookup('text.fallback', 'fallback'));
-eq('application/octet-stream', mime.lookup('constructor'));
-eq('text/plain', mime.lookup('TEXT.TXT'));
-eq('text/event-stream', mime.lookup('text/event-stream'));
-eq('application/x-web-app-manifest+json', mime.lookup('text.webapp'));
+eq('text/plain', mime.lookup('text.txt')); // normal file
+eq('text/plain', mime.lookup('TEXT.TXT')); // uppercase
+eq('text/plain', mime.lookup('dir/text.txt')); // dir + file
+eq('text/plain', mime.lookup('.text.txt')); // hidden file
+eq('text/plain', mime.lookup('.txt')); // nameless
+eq('text/plain', mime.lookup('txt')); // extension-only
+eq('text/plain', mime.lookup('/txt')); // extension-less ()
+eq('text/plain', mime.lookup('\\txt')); // Windows, extension-less
+eq('application/octet-stream', mime.lookup('text.nope')); // unrecognized
+eq('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
//
// Test extensions
@@ -43,10 +43,10 @@ eq('html', mime.extension('text/html; charset=UTF-8'));
eq('html', mime.extension('text/html ; charset=UTF-8'));
eq('html', mime.extension('text/html;charset=UTF-8'));
eq('html', mime.extension('text/Html;charset=UTF-8'));
-eq(undefined, mime.extension('constructor'));
+eq(undefined, mime.extension('unrecognized'));
//
-// Test node types
+// Test node.types lookups
//
eq('application/font-woff', mime.lookup('file.woff'));
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/node-mime.git
More information about the Pkg-javascript-commits
mailing list