Pārlūkot izejas kodu

Recognize .jsonc files automatically (#2398)

Closes https://github.com/XTLS/Xray-core/issues/2399
冬花ice 2 gadi atpakaļ
vecāks
revīzija
017b56adf5
2 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  1. 1 1
      core/config.go
  2. 2 2
      main/run.go

+ 1 - 1
core/config.go

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

+ 2 - 2
main/run.go

@@ -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)$`
 	}
 }