diff --git a/internal/cnf/parser/nginx/decoder.go b/internal/cnf/parser/nginx/decoder.go index beb2e31..9030c74 100644 --- a/internal/cnf/parser/nginx/decoder.go +++ b/internal/cnf/parser/nginx/decoder.go @@ -74,10 +74,10 @@ func (d *decoder) Decode(v interface{}) error { // 2. comment if line[0] == '#' { l.Type = COMMENT - l.Components = []string{strings.Trim(line[1:], " \t")} + l.Components = []string{line[1:]} } else if line[0] == ';' { l.Type = COLONCOMMENT - l.Components = []string{strings.Trim(line[1:], " \t")} + l.Components = []string{line[1:]} } else if line[0] == '}' { l.Type = SECTIONEND if len(stack) < 1 { diff --git a/internal/cnf/parser/nginx/decoder_test.go b/internal/cnf/parser/nginx/decoder_test.go index 8a3b056..c391b68 100644 --- a/internal/cnf/parser/nginx/decoder_test.go +++ b/internal/cnf/parser/nginx/decoder_test.go @@ -39,16 +39,16 @@ func TestEachLineType(t *testing.T) { {"#some comment\n", []string{"some comment"}, COMMENT}, {"#some\tcomment\n", []string{"some\tcomment"}, COMMENT}, - {"# some comment \n", []string{"some comment"}, COMMENT}, - {"# some comment \t\n", []string{"some comment"}, COMMENT}, - {"\t# some comment {\n", []string{"some comment {"}, COMMENT}, + {"# some comment \n", []string{" some comment"}, COMMENT}, + {"# some comment \t\n", []string{" some comment"}, COMMENT}, + {"\t# some comment {\n", []string{" some comment {"}, COMMENT}, {";some comment\n", []string{"some comment"}, COLONCOMMENT}, - {"; some\tcomment\n", []string{"some\tcomment"}, COLONCOMMENT}, - {"; some comment\n", []string{"some comment"}, COLONCOMMENT}, - {"; some comment \n", []string{"some comment"}, COLONCOMMENT}, - {"; some comment \t\n", []string{"some comment"}, COLONCOMMENT}, - {"\t; some comment {\n", []string{"some comment {"}, COLONCOMMENT}, + {"; some\tcomment\n", []string{" some\tcomment"}, COLONCOMMENT}, + {"; some comment\n", []string{" some comment"}, COLONCOMMENT}, + {"; some comment \n", []string{" some comment"}, COLONCOMMENT}, + {"; some comment \t\n", []string{" some comment"}, COLONCOMMENT}, + {"\t; some comment {\n", []string{" some comment {"}, COLONCOMMENT}, } for i, test := range tests {