Skip to content

Commit

Permalink
Fix: match csv spec, RFC4180 - 7
Browse files Browse the repository at this point in the history
will remove all extra pair of double quotes and escape only 2 double quotes
  • Loading branch information
iliasbhal committed Feb 7, 2019
1 parent 4f2eac5 commit b8bd978
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helpers/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ function fromCsvStringToArray(string, tableName) {

if (!reValid.test(string)) {

if (string.match(/,"(("")+)",/g) ) { // remove all extra double-quote if value should be an empty string
string = string.replace(/,"(("")+)",/g, ',"",');
if (string.match(/,"(("")+)",/) ) { // remove all extra double-quote if value should be -> ""
string = string.replace(/,"(("")+)",/g, ',"\\"\\"",');
return fromCsvStringToArray(string, tableName);
} else if (string.match(/""""/) ) {
string = string.replace(/""""/g, '\\"\\"');
Expand Down

0 comments on commit b8bd978

Please sign in to comment.