cmd: Fix panic related to config filename (fix #5919)

This commit is contained in:
Matthew Holt 2024-04-11 17:04:43 -06:00
parent 185ed6fe7c
commit e1f4b83ffa
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5

View File

@ -165,7 +165,7 @@ func loadConfigWithLogger(logger *zap.Logger, configFile, adapterName string) ([
baseConfigExt := filepath.Ext(baseConfig)
if (strings.HasPrefix(baseConfig, "caddyfile") ||
strings.HasSuffix(baseConfig, ".caddyfile")) &&
caddyconfig.GetAdapter(baseConfigExt[1:]) == nil &&
(len(baseConfigExt) == 0 || caddyconfig.GetAdapter(baseConfigExt[1:]) == nil) &&
baseConfigExt != ".json" &&
adapterName == "" {
adapterName = "caddyfile"