Skip to content

Commit

Permalink
feat: handle common comment case
Browse files Browse the repository at this point in the history
  • Loading branch information
mja00 committed Nov 27, 2024
1 parent e8b91f5 commit c1a1ce2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ const unsafe = (val) => {
}
isEscaping = false;
}else if(commentChars.includes(char)){
break;
// Check if there's spaces around this comment character
// If there is, then we're done parsing at the character before this one
if(val.charAt(i - 1) === ' ' && val.charAt(i + 1) === ' '){
break;
}
}else if(char === '\\'){
isEscaping = true;
}else{
Expand Down
2 changes: 1 addition & 1 deletion test/foo.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ test('ignores invalid line (=)', function(t){

test("unsafe escape values", function(t){
t.equal(ini.unsafe(''), '');
t.equal(ini.unsafe('x;y'), 'x');
t.equal(ini.unsafe('x;y'), 'xy');
t.equal(ini.unsafe('x # y'), 'x');
t.equal(ini.unsafe('x "\\'), 'x "\\');
t.end();
Expand Down

0 comments on commit c1a1ce2

Please sign in to comment.