fix read_source_map inline bug

1.  The previous regExp may match a map-like string or otherthings before the real inline map, which must in the end of the file. And,
2. The eol in javascript is not only `\n`, but also `\r` `\u2028` `\u2029`, and even no eol before (start of the file).
This commit is contained in:
龙腾道 2018-11-16 10:45:02 +08:00
parent ea999b0e92
commit 4dba4da563

View File

@ -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 = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
if (!match) {
AST_Node.warn("inline source map not found: " + name);
return null;