diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/minify.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/minify.js b/lib/minify.js index 5f865c63..1bb6309c 100644 --- a/lib/minify.js +++ b/lib/minify.js @@ -8,7 +8,7 @@ var to_base64 = typeof btoa == "undefined" ? function(str) { } : btoa; function read_source_map(name, code) { - var match = /\n\/\/# sourceMappingURL=data:application\/json(;.*?)?;base64,(.*)/.exec(code); + var match = /\n\/\/# sourceMappingURL=data:application\/json(;.*?)?;base64,(\S+)\s*$/.exec(code); if (!match) { AST_Node.warn("inline source map not found: " + name); return null; @@ -204,10 +204,14 @@ function minify(files, options) { result.code = stream.get(); if (options.sourceMap) { result.map = options.output.source_map.toString(); - if (options.sourceMap.url == "inline") { - result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(result.map); - } else if (options.sourceMap.url) { - result.code += "\n//# sourceMappingURL=" + options.sourceMap.url; + var url = options.sourceMap.url; + if (url) { + result.code = result.code.replace(/\n\/\/# sourceMappingURL=\S+\s*$/, ""); + if (url == "inline") { + result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(result.map); + } else { + result.code += "\n//# sourceMappingURL=" + url; + } } } } |