Skip to content

Commit a03be43

Browse files
committed
Fix extension getter without path
1 parent d75b318 commit a03be43

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

dist/mimer.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mimer.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mimer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/exec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636
},
3737
_extGetter = function (fileName) {
38-
return fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2);
38+
return fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2) || fileName.split('.').join('');
3939
};
4040

4141
Mimer.prototype = {
@@ -62,6 +62,8 @@
6262

6363
ext = _extGetter(path);
6464

65+
console.log('_______________', ext);
66+
6567
return this.list[ext] || generic;
6668
},
6769
list: (typeof process !== 'undefined' && process.cwd) ? require('./data/parser')(__dirname + '/data/mime.types') : $_MIMER_DATA_LIST

test/run.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
if (extList.hasOwnProperty(ext)) {
7676
expected = extList[ext];
7777

78+
cases['should run as function and get extension .' + ext] = function () {
79+
assert.strictEqual(Mimer(ext), expected);
80+
};
81+
7882
cases['should run as function and get extension .' + ext + ' from ' + path + ext] = function () {
7983
assert.strictEqual( Mimer(path + ext) , expected);
8084
};

0 commit comments

Comments
 (0)