Skip to content

Commit

Permalink
Allow whitespace between regex & some of the things that can follow it
Browse files Browse the repository at this point in the history
Fixes #242
  • Loading branch information
matthiasmullie committed Apr 4, 2018
1 parent 62dac3b commit 473896b
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 @@ -264,7 +264,7 @@ protected function extractRegex()
);
$delimiters = array_fill(0, count($propertiesAndMethods), '/');
$propertiesAndMethods = array_map('preg_quote', $propertiesAndMethods, $delimiters);
$after = '(?=\s*[\.,;\)\}&\|+]|\/\/|$|\.('.implode('|', $propertiesAndMethods).'))';
$after = '(?=\s*([\.,;\)\}&\|+]|\/\/|$|\.('.implode('|', $propertiesAndMethods).')))';
$this->registerPattern('/'.$before.'\K'.$pattern.$after.'/', $callback);

// regular expressions following a `)` are rather annoying to detect...
Expand Down
6 changes: 6 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,12 @@ function someOtherFunction() {
var largeScreen=2048',
);

// https://github.com/matthiasmullie/minify/issues/242
$tests[] = array(
"/^\[(x| )\](?=\s)/i // Must follow listRE",
"/^\[(x| )\](?=\s)/i",
);

// 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 473896b

Please sign in to comment.