Skip to content

Commit

Permalink
Merge pull request #124 from CGLOB/master
Browse files Browse the repository at this point in the history
To identify coorect end of the regex
  • Loading branch information
tedivm committed Jun 19, 2023
2 parents e72133d + 70b18f1 commit 7cb41f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/JShrink/Minifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Resources/jshrink/input/regex_end_string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
escapeCssMeta: function( string ) {
return (string || '').replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" );
},
5 changes: 1 addition & 4 deletions tests/Resources/jshrink/output/regex_close.js
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,
'\\$1'
)
}
function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,'\\$1')}
1 change: 1 addition & 0 deletions tests/Resources/jshrink/output/regex_end_string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
escapeCssMeta:function(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1");},

0 comments on commit 7cb41f8

Please sign in to comment.