markty-TOML icon indicating copy to clipboard operation
markty-TOML copied to clipboard

Incorrect output when parsing `.git/config`

Open aleclarson opened this issue 3 years ago • 4 comments

If a branch name contains a dot, the output is incorrect.

Repro

import toml from 'markty-toml'

toml(`
[branch "v1.0"]
        remote = origin
        merge = refs/heads/v1.0
`)

Expected:

{
  'branch "v1.0"': { remote: 'origin', merge: 'refs/heads/v1.0' }
}

Actual:

{
  'branch "v1': { '0"': { remote: 'origin', merge: 'refs/heads/v1.0' } }
}

aleclarson avatar May 11 '21 02:05 aleclarson

Interestingly, the ini package has the same problem :)

https://github.com/npm/ini/issues/22

aleclarson avatar May 11 '21 02:05 aleclarson

Mmmm it has been a long time I have not work on this project to be honest. You might be totally right, that's an edge case that I missed completely...

For the time being, could you try to put your values between quotes ??

Like

​[branch "v1.0"]​
​        remote = "origin​"
​        merge = "refs/heads/v1.0​"

Jonarod avatar May 11 '21 05:05 Jonarod

If you look closer at my example, the problem is with the [branch "v1.0"] part :)

I've worked around this by using config-ini-parser instead

aleclarson avatar May 11 '21 12:05 aleclarson

Oh you are right, sorry for that I misread.

Yeah, there is no way around that for the moment.

Jonarod avatar May 11 '21 22:05 Jonarod