Browse Source

got tests to pass if no newline at EOF

pull/542/head
jaymeans 7 years ago
parent
commit
0d492daafe
  1. 2
      papaparse.js
  2. 4
      tests/test-cases.js

2
papaparse.js

@ -1257,7 +1257,7 @@
{ {
input = input.substr(0, 1024 * 1024); // max length 1 MB input = input.substr(0, 1024 * 1024); // max length 1 MB
// Replace all the text inside quotes // Replace all the text inside quotes
var re = new RegExp(quoteChar + '(.*?)' + quoteChar, 'gm'); var re = new RegExp(quoteChar + '([^]*?)' + quoteChar, 'gm');
input = input.replace(re, ''); input = input.replace(re, '');
var r = input.split('\r'); var r = input.split('\r');

4
tests/test-cases.js

@ -1211,7 +1211,7 @@ var PARSE_TESTS = [
}, },
{ {
description: "Carriage return in header inside quotes, with line feed endings", description: "Carriage return in header inside quotes, with line feed endings",
input: '"a\r\na","b"\n"c","d"\n"e","f"\n"g","h"\n"i","j"\n', input: '"a\r\na","b"\n"c","d"\n"e","f"\n"g","h"\n"i","j"',
config: {}, config: {},
expected: { expected: {
data: [['a\r\na', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h'], ['i', 'j']], data: [['a\r\na', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h'], ['i', 'j']],
@ -1220,7 +1220,7 @@ var PARSE_TESTS = [
}, },
{ {
description: "Line feed in header inside quotes, with carriage return + line feed endings", description: "Line feed in header inside quotes, with carriage return + line feed endings",
input: '"a\na","b"\r\n"c","d"\r\n"e","f"\r\n"g","h"\r\n"i","j"\r\n', input: '"a\na","b"\r\n"c","d"\r\n"e","f"\r\n"g","h"\r\n"i","j"',
config: {}, config: {},
expected: { expected: {
data: [['a\na', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h'], ['i', 'j']], data: [['a\na', 'b'], ['c', 'd'], ['e', 'f'], ['g', 'h'], ['i', 'j']],

Loading…
Cancel
Save