diff --git a/lib/coffee-script/lexer.js b/lib/coffee-script/lexer.js index 4c4f2850..37ab04ad 100644 --- a/lib/coffee-script/lexer.js +++ b/lib/coffee-script/lexer.js @@ -242,7 +242,9 @@ if (i === $) { value = value.replace(TRAILING_BLANK_LINE, ''); } - value = value.replace(indentRegex, ''); + if (indentRegex) { + value = value.replace(indentRegex, ''); + } return value; }; })(this)); diff --git a/src/lexer.coffee b/src/lexer.coffee index 7bf28be7..ea7e54a8 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -217,7 +217,7 @@ exports.Lexer = class Lexer value = @formatString value value = value.replace LEADING_BLANK_LINE, '' if i is 0 value = value.replace TRAILING_BLANK_LINE, '' if i is $ - value = value.replace indentRegex, '' + value = value.replace indentRegex, '' if indentRegex value else @mergeInterpolationTokens tokens, {delimiter}, (value, i) => diff --git a/test/strings.coffee b/test/strings.coffee index 7797b291..6eb314d5 100644 --- a/test/strings.coffee +++ b/test/strings.coffee @@ -342,6 +342,9 @@ eq """ "\\\" """, ' "\\" ' eq ''' <- keep these spaces -> ''', ' <- keep these spaces -> ' +eq '''undefined''', 'undefined' +eq """undefined""", 'undefined' + test "#1046, empty string interpolations", -> eq "#{ }", ''