@@ -154,7 +154,21 @@ export const Csv2Json = function(options: FullCsv2JsonOptions) {
154154 stateVariables . startIndex = index + eolDelimiterLength ;
155155 stateVariables . parsingValue = true ;
156156 stateVariables . insideWrapDelimiter = charAfter === options . delimiter . wrap ;
157- } else if ( ( charBefore !== options . delimiter . wrap || stateVariables . justParsedDoubleQuote && charBefore === options . delimiter . wrap ) &&
157+ } else if ( character === options . delimiter . wrap && charBefore === options . delimiter . field &&
158+ ! stateVariables . insideWrapDelimiter && ! stateVariables . parsingValue ) {
159+ // If we reached a wrap delimiter after a comma and we aren't inside a wrap delimiter
160+
161+ stateVariables . startIndex = index ;
162+ stateVariables . insideWrapDelimiter = true ;
163+ stateVariables . parsingValue = true ;
164+
165+ // If the next character(s) are an EOL delimiter, then skip them so we don't parse what we've seen as another value
166+ if ( utils . getNCharacters ( csv , index + 1 , eolDelimiterLength ) === options . delimiter . eol ) {
167+ index += options . delimiter . eol . length + 1 ; // Skip past EOL
168+ }
169+ }
170+
171+ else if ( ( charBefore !== options . delimiter . wrap || stateVariables . justParsedDoubleQuote && charBefore === options . delimiter . wrap ) &&
158172 character === options . delimiter . wrap && utils . getNCharacters ( csv , index + 1 , eolDelimiterLength ) === options . delimiter . eol ) {
159173 // If we reach a wrap which is not preceded by a wrap delim and the next character is an EOL delim (ie. *"\n)
160174
@@ -174,13 +188,6 @@ export const Csv2Json = function(options: FullCsv2JsonOptions) {
174188 stateVariables . startIndex = index + 2 ; // next value starts after the field delimiter
175189 stateVariables . insideWrapDelimiter = false ;
176190 stateVariables . parsingValue = false ;
177- } else if ( character === options . delimiter . wrap && charBefore === options . delimiter . field &&
178- ! stateVariables . insideWrapDelimiter && ! stateVariables . parsingValue ) {
179- // If we reached a wrap delimiter after a comma and we aren't inside a wrap delimiter
180-
181- stateVariables . startIndex = index ;
182- stateVariables . insideWrapDelimiter = true ;
183- stateVariables . parsingValue = true ;
184191 } else if ( character === options . delimiter . wrap && charBefore === options . delimiter . field &&
185192 ! stateVariables . insideWrapDelimiter && stateVariables . parsingValue ) {
186193 // If we reached a wrap delimiter with a field delimiter after it (ie. ,"*)
0 commit comments