Skip to content

Commit 128af6d

Browse files
Initialize options by default (#56)
fix options
1 parent e73b7dd commit 128af6d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

parser/parser.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ type options struct {
2424
skipValidDirectivesErr bool
2525
}
2626

27+
func defaultOptions() options {
28+
return options{
29+
parseInclude: false,
30+
skipIncludeParsingErr: false,
31+
skipComments: false,
32+
customDirectives: map[string]string{},
33+
skipValidSubDirectiveBlock: map[string]struct{}{},
34+
skipValidDirectivesErr: false,
35+
}
36+
}
37+
2738
// Parser is an nginx config parser
2839
type Parser struct {
2940
opts options
@@ -70,7 +81,7 @@ func WithSkipIncludeParsingErr() Option {
7081
// WithDefaultOptions default options
7182
func WithDefaultOptions() Option {
7283
return func(p *Parser) {
73-
p.opts = options{}
84+
p.opts = defaultOptions()
7485
}
7586
}
7687

@@ -136,7 +147,7 @@ func NewParserFromLexer(lexer *lexer, opts ...Option) *Parser {
136147
configRoot, _ := filepath.Split(lexer.file)
137148
parser := &Parser{
138149
lexer: lexer,
139-
opts: options{customDirectives: make(map[string]string), skipValidSubDirectiveBlock: map[string]struct{}{}},
150+
opts: defaultOptions(),
140151
parsedIncludes: make(map[*config.Include]*config.Config),
141152
configRoot: configRoot,
142153
}

0 commit comments

Comments
 (0)