caddyserver / website

The Caddy website
146 stars 144 forks source link

matcher format for multiple sites share same definition #395

Open sospartan opened 1 month ago

sospartan commented 1 month ago

I found put a space before comma will not parsed as two hosts, for example:

abc.com , ab.com {
...
}

Is this a reasonable format? I'd like make a PR about it. To quote the docs

If multiple sites share the same definition, you can list all of them together, either with spaces or commas.

Although the examples in the documentation are in the form of host immediately followed by a comma, this is, after all, not explicitly stated.

mholt commented 1 month ago

We should probably state that in the docs: there should be a space after the comma, not before. What you have there looks weird IMO :innocent:

I'm going to transfer this to the website repo so we can work on it there.

sospartan commented 1 month ago

https://github.com/caddyserver/caddy/blob/e7ecc7ede2f0f749530b0c2e685b99954b9591ce/caddyconfig/caddyfile/parse.go#L260
Noticed here is already handle the situation comma without space. I agreed these looks wired too. But I think support use comma to separating sites no matter spaces will make caddyfile's syntax more fault tolerant. Space is quite easily neglected. And the 'wired' part may handle it in 'formatter'.

mholt commented 1 month ago

We don't actually want "fault tolerant" Caddyfiles, we want consistent ones :slightly_smiling_face:

So the current behavior is correct, but we can clarify the specifics in the docs.