Skip to content

Commit a236819

Browse files
committed
fix: adjust for substring logic
1 parent cb54cf5 commit a236819

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/csv2json.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ export const Csv2Json = function(options: FullCsv2JsonOptions) {
310310
lastChar = fieldValue[lastIndex];
311311
// If the field starts and ends with a wrap delimiter
312312
if (firstChar === options.delimiter.wrap && lastChar === options.delimiter.wrap) {
313-
return fieldValue.substring(1, lastIndex - 1);
313+
// Handle the case where the field is just a pair of wrap delimiters
314+
return fieldValue.length <= 2 ? "" : fieldValue.substring(1, lastIndex);
314315
}
315316
return fieldValue;
316317
}

0 commit comments

Comments
 (0)