Skip to content

Commit

Permalink
Merge pull request #5 from grifart/fixed-windows-line-endings
Browse files Browse the repository at this point in the history
decoder: fixed support for CRLF line-endings
  • Loading branch information
matej21 authored May 18, 2017
2 parents cc4ef23 + 5bebf81 commit 6a2e52b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function decoder(output) {
} else if (input.substr(0, 3) == "\xEF\xBB\xBF") { // BOM
input = input.substr(3);
}
this.input = "\n" + "" + input.replace("\r", ""); // \n forces indent detection
this.input = "\n" + "" + input.replace(/\r\n/g, "\n"); // \n forces indent detection

var regexp = new RegExp('(' + "" + decoder.patterns.join(')|(') + "" + ')', 'mig');
this.tokens = this.split(regexp, this.input);
Expand Down
12 changes: 12 additions & 0 deletions test/Decoder.inline.array.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ suite('Decoder.inline.array', function () {
f: null
});
});

test('5 - crlf', function () {
assertNeon.equal(neon.decode("{a,\r\nb\r\nc: 1,\r\nd: 1,\r\n\r\ne: 1\r\nf:\r\n}"), {
0: "a",
1: "b",
c: 1,
d: 1,
e: 1,
f: null
});
});

test('entity 1', function () {
assert.ok(neon.decode("@item(a, b)") instanceof neon.Entity);
});
Expand Down

0 comments on commit 6a2e52b

Please sign in to comment.