Skip to content

Commit

Permalink
enhance: skip the directives validation check of gonginx
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Jan 16, 2024
1 parent 99d6983 commit 1658e4b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,6 @@ require (
)

replace (
github.com/tufanbarisyildirim/gonginx v0.0.0-20240109151651-bb3e845a7a2a => github.com/0xJacky/gonginx v0.0.0-20240114153809-6a105e85b7c3
github.com/tufanbarisyildirim/gonginx v0.0.0-20240109151651-bb3e845a7a2a => github.com/0xJacky/gonginx v0.0.0-20240116144320-46847e98c3f8
gopkg.in/ns1/ns1-go.v2 v2.7.8 => gopkg.in/ns1/ns1-go.v2 v2.7.6
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcP
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
github.com/0xJacky/gonginx v0.0.0-20240114153809-6a105e85b7c3 h1:zf2Ynrcf96871zUDsC/ZcYHiCyb8J2lNhfysNWG7I6g=
github.com/0xJacky/gonginx v0.0.0-20240114153809-6a105e85b7c3/go.mod h1:4fTjBxMoWGOIVnGFSTS9GAZ0yMyiGzTdATQS0krQv18=
github.com/0xJacky/gonginx v0.0.0-20240116144320-46847e98c3f8 h1:WsRlIe5lYWbgVwXsNroC9sSw/q7Dz/XeCCiyFyzm1oQ=
github.com/0xJacky/gonginx v0.0.0-20240116144320-46847e98c3f8/go.mod h1:4fTjBxMoWGOIVnGFSTS9GAZ0yMyiGzTdATQS0krQv18=
github.com/0xJacky/pofile v0.2.1 h1:ceNyprJOpo7wPPR0rCOuR1gfjYiS8t9YBc73tSLnlDc=
github.com/0xJacky/pofile v0.2.1/go.mod h1:hOZmte1hWostNs9KCwFRhKM7hf0d19zfWosopngij74=
github.com/AdamSLevy/jsonrpc2/v14 v14.1.0 h1:Dy3M9aegiI7d7PF1LUdjbVigJReo+QOceYsMyFh9qoE=
Expand Down
2 changes: 1 addition & 1 deletion internal/nginx/build_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (c *NgxConfig) BuildConfig() (content string, err error) {

content += fmt.Sprintf("%sserver {\n%s}\n\n", comments, server)
}
p := parser.NewStringParser(content)
p := parser.NewStringParser(content, parser.WithSkipValidDirectivesErr())
config, err := p.Parse()
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion internal/nginx/format_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func (c *NgxConfig) FmtCode() (fmtContent string) {
}

func FmtCode(content string) (fmtContent string, err error) {
p := parser.NewStringParser(content)
p := parser.NewStringParser(content, parser.WithSkipValidDirectivesErr())
c, err := p.Parse()
if err != nil {
return
Expand Down
4 changes: 2 additions & 2 deletions internal/nginx/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func parse(block gonginx.IBlock, ngxConfig *NgxConfig) (err error) {
}

func ParseNgxConfigByContent(content string) (ngxConfig *NgxConfig, err error) {
p := parser.NewStringParser(content)
p := parser.NewStringParser(content, parser.WithSkipValidDirectivesErr())
c, err := p.Parse()
if err != nil {
return
Expand All @@ -174,7 +174,7 @@ func ParseNgxConfigByContent(content string) (ngxConfig *NgxConfig, err error) {
}

func ParseNgxConfig(filename string) (ngxConfig *NgxConfig, err error) {
p, err := parser.NewParser(filename)
p, err := parser.NewParser(filename, parser.WithSkipValidDirectivesErr())
if err != nil {
return nil, errors.Wrap(err, "error ParseNgxConfig")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func ParseTemplate(path, name string, bindData map[string]Variable) (c ConfigDet

content = buf.String()

p := parser.NewStringParser(content)
p := parser.NewStringParser(content, parser.WithSkipValidDirectivesErr())
config, err := p.Parse()
if err != nil {
return
Expand Down

0 comments on commit 1658e4b

Please sign in to comment.