Skip to content

Commit

Permalink
Regexes can follow !
Browse files Browse the repository at this point in the history
Fixes #197
  • Loading branch information
matthiasmullie committed Sep 14, 2017
1 parent e13f94a commit 678725d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/JS.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected function extractRegex()
// of the RegExp methods (a `\` followed by a variable or value is
// likely part of a division, not a regex)
$keywords = array('do', 'in', 'new', 'else', 'throw', 'yield', 'delete', 'return', 'typeof');
$before = '(?P<before>[=:,;\}\(\{&\|]|^|'.implode('|', $keywords).')';
$before = '(?P<before>[=:,;\}\(\{&\|!]|^|'.implode('|', $keywords).')';
$propertiesAndMethods = array(
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Properties
'prototype',
Expand Down
6 changes: 6 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,12 @@ function someOtherFunction() {
'if(!0){console.log(!0)}else{console.log(!1)}',
);

// https://github.com/matthiasmullie/minify/issues/197
$tests[] = array(
'if(!e.allow_html_data_urls&&V.test(k)&&!/^data:image\//i.test(k))return',
'if(!e.allow_html_data_urls&&V.test(k)&&!/^data:image\//i.test(k))return',
);

// known minified files to help doublecheck changes in places not yet
// anticipated in these tests
$files = glob(__DIR__.'/sample/minified/*.js');
Expand Down

0 comments on commit 678725d

Please sign in to comment.