@@ -5400,6 +5400,16 @@ const normalize_options = function(opts){
54005400 ] , options ) ;
54015401 }
54025402 }
5403+ // Normalize option `comment_no_infix`
5404+ if ( options . comment_no_infix === undefined || options . comment_no_infix === null || options . comment_no_infix === false ) {
5405+ options . comment_no_infix = false ;
5406+ } else if ( options . comment_no_infix !== true ) {
5407+ throw new CsvError ( 'CSV_INVALID_OPTION_COMMENT' , [
5408+ 'Invalid option comment_no_infix:' ,
5409+ 'value must be a boolean,' ,
5410+ `got ${ JSON . stringify ( options . comment_no_infix ) } `
5411+ ] , options ) ;
5412+ }
54035413 // Normalize option `delimiter`
54045414 const delimiter_json = JSON . stringify ( options . delimiter ) ;
54055415 if ( ! Array . isArray ( options . delimiter ) ) options . delimiter = [ options . delimiter ] ;
@@ -5761,7 +5771,7 @@ const transform = function(original_options = {}) {
57615771 } ,
57625772 // Central parser implementation
57635773 parse : function ( nextBuf , end , push , close ) {
5764- const { bom, encoding, from_line, ltrim, max_record_size, raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this . options ;
5774+ const { bom, comment_no_infix , encoding, from_line, ltrim, max_record_size, raw, relax_quotes, rtrim, skip_empty_lines, to, to_line} = this . options ;
57655775 let { comment, escape, quote, record_delimiter} = this . options ;
57665776 const { bomSkipped, previousBuf, rawBuffer, escapeIsQuote} = this . state ;
57675777 let buf ;
@@ -5960,7 +5970,7 @@ const transform = function(original_options = {}) {
59605970 continue ;
59615971 }
59625972 const commentCount = comment === null ? 0 : this . __compareBytes ( comment , buf , pos , chr ) ;
5963- if ( commentCount !== 0 ) {
5973+ if ( commentCount !== 0 && ( comment_no_infix === false || this . state . field . length === 0 ) ) {
59645974 this . state . commenting = true ;
59655975 continue ;
59665976 }
0 commit comments