Skip to content

Commit 8bf7dfc

Browse files
aMarCruzstefanpenner
authored andcommitted
Support charset in inlined sourcemap
1 parent 5793b85 commit 8bf7dfc

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;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
@@ -92,6 +92,16 @@ tests['Valid Minifyified bundle with inline sourcemap should not throw'] = funct
9292
}, 'Valid Minifyified inline sourcemap and inline sourceContent should not throw');
9393
};
9494

95+
tests['Valid Minifyified bundle with inline sourcemap and charset should not throw'] = function () {
96+
var mfDir = path.join(validDir, 'Minifyified')
97+
, min = fs.readFileSync(path.join(mfDir, 'bundle.min.js')).toString()
98+
.replace('/json;base64,', '/json;charset=utf-8;base64,');
99+
100+
assert.doesNotThrow(function () {
101+
validate(min);
102+
}, 'Valid Minifyified inline sourcemap and inline sourceContent should not throw');
103+
};
104+
95105
tests['Valid Babel map should not throw'] = function () {
96106
var babelDir = path.join(validDir, 'Babel')
97107
, map = fs.readFileSync(path.join(babelDir, 'router.js.map')).toString();

0 commit comments

Comments
 (0)