Skip to content

Commit

Permalink
Merge pull request #140 from RReverser/newline-before-string-token
Browse files Browse the repository at this point in the history
js: Newline before string is as significant as before other literals
  • Loading branch information
tdewolff committed May 10, 2017
2 parents 7c0f30b + 335f882 commit 74b1505
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (o *Minifier) Minify(_ *minify.M, w io.Writer, r io.Reader, _ map[string]st
} else {
first := data[0]
if (prev == js.IdentifierToken || prev == js.NumericToken || prev == js.PunctuatorToken || prev == js.StringToken || prev == js.RegexpToken) &&
(tt == js.IdentifierToken || tt == js.NumericToken || tt == js.PunctuatorToken || tt == js.RegexpToken) {
(tt == js.IdentifierToken || tt == js.NumericToken || tt == js.StringToken || tt == js.PunctuatorToken || tt == js.RegexpToken) {
if lineTerminatorQueued && (prev != js.PunctuatorToken || prevLast == '}' || prevLast == ']' || prevLast == ')' || prevLast == '+' || prevLast == '-' || prevLast == '"' || prevLast == '\'') &&
(tt != js.PunctuatorToken || first == '{' || first == '[' || first == '(' || first == '+' || first == '-' || first == '!' || first == '~') {
if _, err := w.Write(newlineBytes); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions js/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func TestJS(t *testing.T) {
{"a\n\nb", "a\nb"},
{"a// comment\nb", "a\nb"},
{"''\na", "''\na"},
{"''\n''", "''''"},
{"''\n''", "''\n''"},
{"]\n0", "]\n0"},
{"a\n{", "a\n{"},
{";\na", ";a"},
{",\na", ",a"},
{"}\na", "}\na"},
{"+\na", "+\na"},
{"+\n(", "+\n("},
{"+\n\"\"", "+\"\""},
{"+\n\"\"", "+\n\"\""},
{"a + ++b", "a+ ++b"}, // JSMin caution
{"var a=/\\s?auto?\\s?/i\nvar", "var a=/\\s?auto?\\s?/i\nvar"}, // #14
{"var a=0\n!function(){}", "var a=0\n!function(){}"}, // #107
Expand Down

0 comments on commit 74b1505

Please sign in to comment.