Skip to content

Commit 496be06

Browse files
aMarCruzstefanpenner
authored andcommitted
make the hyphen in "utf-8" optional.
1 parent 8bf7dfc commit 496be06

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ validate = function (min, map, srcs) {
5959
// If no map was given, try to extract it from min
6060
if(map == null) {
6161
try {
62-
var re = /\s*\/\/(?:@|#) sourceMappingURL=data:application\/json;(?:charset=utf-8;)?base64,(\S*)$/m
62+
var re = /\s*\/\/(?:@|#) sourceMappingURL=data:application\/json;(?:charset=utf-?8;)?base64,(\S*)$/m
6363
, map = min.match(re);
6464

6565
map = createBuffer(map[1], 'base64').toString();

tests/unit.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ tests['Valid Minifyified bundle with inline sourcemap and charset should not thr
102102
}, 'Valid Minifyified inline sourcemap and inline sourceContent should not throw');
103103
};
104104

105+
tests['Valid Minifyified bundle with charset without hyphen should not throw'] = function () {
106+
var mfDir = path.join(validDir, 'Minifyified')
107+
, min = fs.readFileSync(path.join(mfDir, 'bundle.min.js')).toString()
108+
.replace('/json;base64,', '/json;charset=utf8;base64,');
109+
110+
assert.doesNotThrow(function () {
111+
validate(min);
112+
}, 'Valid Minifyified inline sourcemap and inline sourceContent should not throw');
113+
};
114+
105115
tests['Valid Babel map should not throw'] = function () {
106116
var babelDir = path.join(validDir, 'Babel')
107117
, map = fs.readFileSync(path.join(babelDir, 'router.js.map')).toString();

0 commit comments

Comments
 (0)