Browse files

Cleaned up stray newlines that would occur around some comments.

  • Loading branch information...
1 parent 2a30cb4 commit 71b0217a6bb2ee903aedd726bfea90bee7e699db @tedivm tedivm committed Jan 26, 2014
View
9 src/JShrink/Minifier.php
@@ -106,7 +106,8 @@ public static function minify($js, $options = array())
self::$jshrink->breakdownScript($js, $currentOptions);
- return ob_get_clean();
+ // Sometimes there's a leading new line, so we trim that out here.
+ return ltrim(ob_get_clean());
} catch (Exception $e) {
if(isset(self::$jshrink))
@@ -134,6 +135,12 @@ protected function breakdownScript($js, $currentOptions)
$js = str_replace("\r\n", "\n", $js);
$this->input = str_replace("\r", "\n", $js);
+ // We add a newline to the end of the script to make it easier to deal
+ // with comments at the bottom of the script- this prevents the stray
+ // comment error that can occur.
+ $this->input .= PHP_EOL;
+
+
$this->a = $this->getReal();
// the only time the length can be higher than 1 is if a conditional
View
1 tests/Resources/jshrink/expect/preserve_license.js
@@ -1,4 +1,3 @@
-
/*!
This comment should be preserved.
*/
View
1 tests/Resources/jshrink/expect/remove_multiline_comments.js
@@ -1,2 +1 @@
-
var test;var test;var test;var test;var test;var test;
View
1 tests/Resources/jshrink/expect/remove_oneline_comments.js
@@ -1,2 +1 @@
-
var test;var test;var test;var test;var test;var test;
View
2 tests/Resources/jshrink/test/remove_multiline_comments.js
@@ -22,4 +22,4 @@ var test;
*
* Even if this one is special!
*
- */
+ */

0 comments on commit 71b0217

Please sign in to comment.