Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 69ef1ab

Browse files
committed
Fixes jashkenas#2389 -- strip the BOM for once and for all
1 parent cc6f045 commit 69ef1ab

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/coffee-script/lexer.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ exports.Lexer = class Lexer
6767
# returns, etc. If we're lexing literate CoffeeScript, strip external Markdown
6868
# by removing all lines that aren't indented by at least four spaces.
6969
clean: (code) ->
70+
code = code.slice(1) if code.charCodeAt(0) is BOM
7071
code = "\n#{code}" if WHITESPACE.test code
7172
code = code.replace(/\r/g, '').replace TRAILING_SPACES, ''
7273
if @literate
@@ -605,6 +606,9 @@ JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED).concat(STRICT_PROSCRIBED)
605606
exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS).concat(STRICT_PROSCRIBED)
606607
exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED
607608

609+
# The character code of the nasty Microsoft madness otherwise known as the BOM.
610+
BOM = 65279
611+
608612
# Token matching regexes.
609613
IDENTIFIER = /// ^
610614
( [$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]* )

0 commit comments

Comments
 (0)