Skip to content

Commit

Permalink
Support decimals without any decimal digits
Browse files Browse the repository at this point in the history
Fixes #46.
Closes #58.
  • Loading branch information
wyozi authored and mathiasbynens committed Oct 2, 2018
1 parent ba4c54b commit 0255949
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions luamin.js
Expand Up @@ -201,6 +201,11 @@
// e.g. `1-` + `-2`
return a + separator + b;
}
var secondLastCharA = a.slice(-2, -1);
if (lastCharA == '.' && secondLastCharA != '.' && regexAlphaNumUnderscore.test(firstCharB)) {
// e.g. `1.` + `print`
return a + separator + b;
}
return a + b;
};

Expand Down
10 changes: 10 additions & 0 deletions tests/tests.js
Expand Up @@ -1023,6 +1023,16 @@
'original': 'a = .1',
'minified': 'a=.1'
},
{
'description': 'NumericLiteral',
'original': 'a = 1.',
'minified': 'a=1.'
},
{
'description': 'NumericLiteral + Any Statement',
'original': 'a = 1.;b=2',
'minified': 'a=1.;b=2'
},
{
'description': 'NumericLiteral',
'original': 'a = 1.1',
Expand Down

0 comments on commit 0255949

Please sign in to comment.