Skip to content

Commit

Permalink
Fix '0' being replaces by first string's value
Browse files Browse the repository at this point in the history
Fixes #99
  • Loading branch information
matthiasmullie committed Mar 1, 2016
1 parent 3176239 commit 272e461
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Minify.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ protected function extractStrings($chars = '\'"')
$minifier = $this;
$callback = function ($match) use ($minifier) {
// check the second index here, because the first always contains a quote
if (!$match[2]) {
if ($match[2] === '') {
/*
* Empty strings need no placeholder; they can't be confused for
* anything else anyway.
Expand Down
6 changes: 6 additions & 0 deletions tests/js/JSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ function isJSON(){str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[
'if(!0){if(!0)console.log("test")}',
);

// https://github.com/matthiasmullie/minify/issues/99
$tests[] = array(
'"object";"object2";"0";"1"',
'"object";"object2";"0";"1"',
);

//update tests' expected results for cross-system compatibility
foreach ($tests as &$test) {
if (!empty($test[1])) {
Expand Down

0 comments on commit 272e461

Please sign in to comment.