Recognize .jsonc files automatically (#2398)

Closes https://github.com/XTLS/Xray-core/issues/2399
This commit is contained in:
冬花ice 2023-08-06 14:47:31 +08:00 committed by GitHub
parent ce89b5d7de
commit 017b56adf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -57,7 +57,7 @@ func GetFormatByExtension(ext string) string {
return "yaml"
case "toml":
return "toml"
case "json":
case "json", "jsonc":
return "json"
default:
return ""

View File

@ -113,13 +113,13 @@ func dirExists(file string) bool {
func getRegepxByFormat() string {
switch strings.ToLower(*format) {
case "json":
return `^.+\.json$`
return `^.+\.(json|jsonc)$`
case "toml":
return `^.+\.toml$`
case "yaml", "yml":
return `^.+\.(yaml|yml)$`
default:
return `^.+\.(json|toml|yaml|yml)$`
return `^.+\.(json|jsonc|toml|yaml|yml)$`
}
}