Skip to content

Commit

Permalink
skip caddyfile adapter for registered file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
omalk98 committed Dec 14, 2023
1 parent fab8fba commit 942e78d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,16 @@ func loadConfigWithLogger(logger *zap.Logger, configFile, adapterName string) ([
}
}

// as a special case, if a config file called "Caddyfile" was
// specified, and no adapter is specified, assume caddyfile adapter
// for convenience
// as a special case, if a config file starts with "caddyfile" or
// has a ".caddyfile" extension, and no adapter is specified, and
// no adapter module name matches the extension, assume
// caddyfile adapter for convenience
baseConfig := strings.ToLower(filepath.Base(configFile))
baseConfigExt := filepath.Ext(baseConfig)
if (strings.HasPrefix(baseConfig, "caddyfile") ||
strings.HasSuffix(baseConfig, ".caddyfile")) &&
filepath.Ext(baseConfig) != ".json" &&
caddyconfig.GetAdapter(baseConfigExt[1:]) == nil &&
baseConfigExt != ".json" &&
adapterName == "" {
adapterName = "caddyfile"
}
Expand Down

0 comments on commit 942e78d

Please sign in to comment.