Skip to content

Commit dc2303d

Browse files
committed
upd sectionHeader to match inline comments
1 parent f683bf5 commit dc2303d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

configparser.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
var (
17-
sectionHeader = regexp.MustCompile(`^\[([^]]+)\]$`)
17+
sectionHeader = regexp.MustCompile(`^\[([^]]+)\]`)
1818
interpolater = regexp.MustCompile(`%\(([^)]*)\)s`)
1919
)
2020

@@ -47,7 +47,7 @@ type ConfigParser struct {
4747

4848
// Keys returns a sorted slice of keys
4949
func (d Dict) Keys() []string {
50-
var keys []string
50+
keys := make([]string, 0, len(d))
5151

5252
for key := range d {
5353
keys = append(keys, key)
@@ -228,7 +228,7 @@ func (p *ConfigParser) ParseReader(in io.Reader) error {
228228
}
229229

230230
if match := sectionHeader.FindStringSubmatch(line); len(match) > 0 {
231-
section := match[1]
231+
section := p.opt.inlineCommentPrefixes.Split(match[1])
232232
if section == p.opt.defaultSection {
233233
curSect = p.defaults
234234
} else if _, present := p.config[section]; !present {

0 commit comments

Comments
 (0)