cmd: Assume Caddyfile if name starts with Caddyfile

And doesn't have .json extension -- in case someone names their
JSON config something like Caddyfile.json, which is unconventional.
This commit is contained in:
Matthew Holt 2020-01-11 13:48:29 -07:00
parent 25dea2903e
commit 8c0c1a7b88
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -137,7 +137,9 @@ func loadConfig(configFile, adapterName string) ([]byte, error) {
// as a special case, if a config file called "Caddyfile" was
// specified, and no adapter is specified, assume caddyfile adapter
// for convenience
if filepath.Base(configFile) == "Caddyfile" && adapterName == "" {
if strings.HasPrefix(filepath.Base(configFile), "Caddyfile") &&
filepath.Ext(configFile) != ".json" &&
adapterName == "" {
adapterName = "caddyfile"
}