From 017b56adf53d4813d01252157140dd9df5688477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AC=E8=8A=B1ice?= <67498111+flowerinsnowdh@users.noreply.github.com> Date: Sun, 6 Aug 2023 14:47:31 +0800 Subject: [PATCH] Recognize .jsonc files automatically (#2398) Closes https://github.com/XTLS/Xray-core/issues/2399 --- core/config.go | 2 +- main/run.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/config.go b/core/config.go index 5892226b..c845e847 100644 --- a/core/config.go +++ b/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 "" diff --git a/main/run.go b/main/run.go index 97967700..1f8a4b88 100644 --- a/main/run.go +++ b/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)$` } }