From 9575fcf9256dd7d15aade0ba34017a56df0835bb Mon Sep 17 00:00:00 2001 From: Nite07 Date: Thu, 9 May 2024 14:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Error=20when=20template=20?= =?UTF-8?q?name=20contains=20"http"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- common/convert.go | 6 +++++- test/country_test.go | 11 ----------- 3 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 test/country_test.go diff --git a/.gitignore b/.gitignore index d9addfc..937e8d8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .vscode/settings.json dist template.json -.idea \ No newline at end of file +.idea +test \ No newline at end of file diff --git a/common/convert.go b/common/convert.go index 432fee3..d243dfe 100644 --- a/common/convert.go +++ b/common/convert.go @@ -161,7 +161,11 @@ func AddCountryGroup(proxies []model.Outbound, groupType string, sortKey string, func MergeTemplate(outbounds []model.Outbound, template string) (string, error) { var config model.Config var err error - if strings.HasPrefix(template, "http") { + isNetworkFile, err := regexp.MatchString(`^https?://`, template) + if err != nil { + return "", err + } + if isNetworkFile { data, err := util.Fetch(template, 3) if err != nil { return "", err diff --git a/test/country_test.go b/test/country_test.go deleted file mode 100644 index a6a5fed..0000000 --- a/test/country_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package model - -import ( - "log" - "sub2sing-box/model" - "testing" -) - -func TestCountry(t *testing.T) { - log.Println(model.GetContryName("US 节点")) -}