From 8c0c1a7b8815866ac3b6c9cf100f18bf2f1bbd6d Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sat, 11 Jan 2020 13:48:29 -0700 Subject: 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. --- cmd/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/main.go b/cmd/main.go index d8e5f7b..54d11d8 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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" } -- cgit v1.2.3