Parse regexes properly

This commit is contained in:
Anthony Van de Gejuchte
2015-02-10 16:57:17 +01:00
committed by Richard van Velzen
parent 605362f89d
commit 7b71344051

View File

@@ -178,8 +178,13 @@ if (BEAUTIFY)
UglifyJS.merge(OUTPUT_OPTIONS, BEAUTIFY);
if (ARGS.comments) {
if (/^\//.test(ARGS.comments)) {
OUTPUT_OPTIONS.comments = new Function("return(" + ARGS.comments + ")")();
if (/^\/.*\/[a-zA-Z]*$/.test(ARGS.comments)) {
var regex_pos = ARGS.comments.lastIndexOf("/");
try {
OUTPUT_OPTIONS.comments = new RegExp(ARGS.comments.substr(1, regex_pos - 1), ARGS.comments.substr(regex_pos + 1));
} catch (e) {
sys.error("ERROR: Invalid --comments: " + e.message);
}
} else if (ARGS.comments == "all") {
OUTPUT_OPTIONS.comments = true;
} else {