Skip to content

Commit

Permalink
Initialize options by default (#56)
Browse files Browse the repository at this point in the history
fix options
  • Loading branch information
tufanbarisyildirim authored Nov 15, 2024
1 parent e73b7dd commit 128af6d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ type options struct {
skipValidDirectivesErr bool
}

func defaultOptions() options {
return options{
parseInclude: false,
skipIncludeParsingErr: false,
skipComments: false,
customDirectives: map[string]string{},
skipValidSubDirectiveBlock: map[string]struct{}{},
skipValidDirectivesErr: false,
}
}

// Parser is an nginx config parser
type Parser struct {
opts options
Expand Down Expand Up @@ -70,7 +81,7 @@ func WithSkipIncludeParsingErr() Option {
// WithDefaultOptions default options
func WithDefaultOptions() Option {
return func(p *Parser) {
p.opts = options{}
p.opts = defaultOptions()
}
}

Expand Down Expand Up @@ -136,7 +147,7 @@ func NewParserFromLexer(lexer *lexer, opts ...Option) *Parser {
configRoot, _ := filepath.Split(lexer.file)
parser := &Parser{
lexer: lexer,
opts: options{customDirectives: make(map[string]string), skipValidSubDirectiveBlock: map[string]struct{}{}},
opts: defaultOptions(),
parsedIncludes: make(map[*config.Include]*config.Config),
configRoot: configRoot,
}
Expand Down

0 comments on commit 128af6d

Please # to comment.