Browse Source

caddyfile: Fix minor bug in formatter

master
Matthew Holt 4 years ago
parent
commit
635f075f18
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 2
      caddyconfig/caddyfile/formatter.go
  2. 11
      caddyconfig/caddyfile/formatter_test.go

2
caddyconfig/caddyfile/formatter.go

@ -78,6 +78,8 @@ func Format(input []byte) []byte {
if comment { if comment {
if ch == '\n' { if ch == '\n' {
comment = false comment = false
nextLine()
continue
} else { } else {
write(ch) write(ch)
continue continue

11
caddyconfig/caddyfile/formatter_test.go

@ -310,6 +310,17 @@ baz`,
input: `redir / /some/#/path`, input: `redir / /some/#/path`,
expect: `redir / /some/#/path`, expect: `redir / /some/#/path`,
}, },
{
description: "brace does not fold into comment above",
input: `# comment
{
foo
}`,
expect: `# comment
{
foo
}`,
},
} { } {
// the formatter should output a trailing newline, // the formatter should output a trailing newline,
// even if the tests aren't written to expect that // even if the tests aren't written to expect that

Loading…
Cancel
Save