Fix regex detection when content is only backslashes

Fixes #182
This commit is contained in:
Matthias Mullie 2017-06-13 17:45:36 +02:00
parent 3fcd6421df
commit 563651cf1b
2 changed files with 7 additions and 1 deletions

View File

@ -222,7 +222,7 @@ class JS extends Minify
return $placeholder;
};
$pattern = '\/.+?(?<!\\\\)(\\\\\\\\)*\/[gimy]*(?![0-9a-zA-Z\/])';
$pattern = '\/.*?(?<!\\\\)(\\\\\\\\)*\/[gimy]*(?![0-9a-zA-Z\/])';
// a regular expression can only be followed by a few operators or some
// of the RegExp methods (a `\` followed by a variable or value is

View File

@ -957,6 +957,12 @@ return el}',
'q=d/4/b.width()',
);
// https://github.com/matthiasmullie/minify/issues/182
$tests[] = array(
'label = input.val().replace(/\\\\/g, \'/\').replace(/.*\//, \'\');',
'label=input.val().replace(/\\\\/g,\'/\').replace(/.*\//,\'\')',
);
// known minified files to help doublecheck changes in places not yet
// anticipated in these tests
$files = glob(__DIR__.'/sample/minified/*.js');