From ba35b9d33b6d6c1e90c695c5d7d409223a96974e Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Tue, 20 Jun 2023 08:13:01 -0500 Subject: [PATCH] Revert "To identify coorect end of the regex" --- src/JShrink/Minifier.php | 2 +- tests/Resources/jshrink/input/regex_end_string.js | 3 --- tests/Resources/jshrink/output/regex_close.js | 5 ++++- tests/Resources/jshrink/output/regex_end_string.js | 1 - 4 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 tests/Resources/jshrink/input/regex_end_string.js delete mode 100644 tests/Resources/jshrink/output/regex_end_string.js diff --git a/src/JShrink/Minifier.php b/src/JShrink/Minifier.php index 365c474..3f07ad8 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 === '/' && (preg_match('/g|\n|i|\)|\.|,|\s/', $this->peek()) === 1)) { + if ($this->a === '/') { break; } diff --git a/tests/Resources/jshrink/input/regex_end_string.js b/tests/Resources/jshrink/input/regex_end_string.js deleted file mode 100644 index 79164ff..0000000 --- a/tests/Resources/jshrink/input/regex_end_string.js +++ /dev/null @@ -1,3 +0,0 @@ -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 fb0880d..4f80faf 100644 --- a/tests/Resources/jshrink/output/regex_close.js +++ b/tests/Resources/jshrink/output/regex_close.js @@ -1 +1,4 @@ -function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,'\\$1')} \ No newline at end of file +function test(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, + '\\$1' + ) +} diff --git a/tests/Resources/jshrink/output/regex_end_string.js b/tests/Resources/jshrink/output/regex_end_string.js deleted file mode 100644 index 1311d14..0000000 --- a/tests/Resources/jshrink/output/regex_end_string.js +++ /dev/null @@ -1 +0,0 @@ -escapeCssMeta:function(string){return(string||'').replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1");}, \ No newline at end of file