Browse Source

Send the original value of the str parameter to the quotes function

pull/703/head
Puzzleton 6 years ago
parent
commit
584b49fc87
  1. 12
      papaparse.js

12
papaparse.js

@ -447,17 +447,17 @@ License: MIT
if (str.constructor === Date) if (str.constructor === Date)
return JSON.stringify(str).slice(1, 25); return JSON.stringify(str).slice(1, 25);
str = str.toString().replace(quoteCharRegex, _escapedQuote); var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
var needsQuotes = (typeof _quotes === 'boolean' && _quotes) var needsQuotes = (typeof _quotes === 'boolean' && _quotes)
|| (typeof _quotes === 'function' && _quotes(str, col)) || (typeof _quotes === 'function' && _quotes(str, col))
|| (Array.isArray(_quotes) && _quotes[col]) || (Array.isArray(_quotes) && _quotes[col])
|| hasAny(str, Papa.BAD_DELIMITERS) || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
|| str.indexOf(_delimiter) > -1 || escapedQuoteStr.indexOf(_delimiter) > -1
|| str.charAt(0) === ' ' || escapedQuoteStr.charAt(0) === ' '
|| str.charAt(str.length - 1) === ' '; || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
return needsQuotes ? _quoteChar + str + _quoteChar : str; return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
} }
function hasAny(str, substrings) function hasAny(str, substrings)

Loading…
Cancel
Save