From 785733ff96d9d23426100df0faf3c06d6d561bfe Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Mon, 10 Nov 2014 19:50:20 -0800 Subject: [PATCH] Fix /**/ bug and add test cases. This fixes #40. --- src/JShrink/Minifier.php | 1 + tests/Resources/jshrink/input/empty_comment.js | 3 +++ tests/Resources/jshrink/output/empty_comment.js | 1 + 3 files changed, 5 insertions(+) create mode 100644 tests/Resources/jshrink/input/empty_comment.js create mode 100644 tests/Resources/jshrink/output/empty_comment.js diff --git a/src/JShrink/Minifier.php b/src/JShrink/Minifier.php index c8f17d9..22ae087 100644 --- a/src/JShrink/Minifier.php +++ b/src/JShrink/Minifier.php @@ -155,6 +155,7 @@ protected function initialize($js, $options) { $this->options = array_merge(static::$defaultOptions, $options); $js = str_replace("\r\n", "\n", $js); + $js = str_replace('/**/', '', $js); $this->input = str_replace("\r", "\n", $js); // We add a newline to the end of the script to make it easier to deal diff --git a/tests/Resources/jshrink/input/empty_comment.js b/tests/Resources/jshrink/input/empty_comment.js new file mode 100644 index 0000000..540aed4 --- /dev/null +++ b/tests/Resources/jshrink/input/empty_comment.js @@ -0,0 +1,3 @@ +/**/ +var test; +/**/ diff --git a/tests/Resources/jshrink/output/empty_comment.js b/tests/Resources/jshrink/output/empty_comment.js new file mode 100644 index 0000000..12e63df --- /dev/null +++ b/tests/Resources/jshrink/output/empty_comment.js @@ -0,0 +1 @@ +var test; \ No newline at end of file