From 4dba4da56362cfa1897ca17937dce21b421283c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Fri, 16 Nov 2018 10:45:02 +0800 Subject: [PATCH] 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). --- lib/minify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/minify.js b/lib/minify.js index d84f6825..39e2979c 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 = /(?:^|[^.])\/\/# 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;