diff --git a/src/JShrink/Minifier.php b/src/JShrink/Minifier.php index 3f07ad8..365c474 100644 --- a/src/JShrink/Minifier.php +++ b/src/JShrink/Minifier.php @@ -626,7 +626,7 @@ protected function saveRegex() $this->echo($this->b); while (($this->a = $this->getChar()) !== false) { - if ($this->a === '/') { + if ($this->a === '/' && (preg_match('/g|\n|i|\)|\.|,|\s/', $this->peek()) === 1)) { break; } diff --git a/tests/Resources/jshrink/input/regex_end_string.js b/tests/Resources/jshrink/input/regex_end_string.js new file mode 100644 index 0000000..79164ff --- /dev/null +++ b/tests/Resources/jshrink/input/regex_end_string.js @@ -0,0 +1,3 @@ +escapeCssMeta: function( string ) { + return (string || '').replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" ); +}, \ No newline at end of file diff --git a/tests/Resources/jshrink/output/regex_close.js b/tests/Resources/jshrink/output/regex_close.js index 4f80faf..fb0880d 100644 --- a/tests/Resources/jshrink/output/regex_close.js +++ b/tests/Resources/jshrink/output/regex_close.js @@ -1,4 +1 @@ -function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, - '\\$1' - ) -} +function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,'\\$1')} \ No newline at end of file diff --git a/tests/Resources/jshrink/output/regex_end_string.js b/tests/Resources/jshrink/output/regex_end_string.js new file mode 100644 index 0000000..1311d14 --- /dev/null +++ b/tests/Resources/jshrink/output/regex_end_string.js @@ -0,0 +1 @@ +escapeCssMeta:function(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1");}, \ No newline at end of file