Skip to content

Commit

Permalink
feat: 输入的suburl自动添加https://前缀
Browse files Browse the repository at this point in the history
  • Loading branch information
UlinoyaPed committed Aug 28, 2023
1 parent 7a728b5 commit afcae30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"io/ioutil"
"net/http"
"strings"

"github.com/gookit/color"
)
Expand Down Expand Up @@ -32,3 +33,10 @@ func Download(url string, filepath string) error {

return nil
}

func AddHTTPSPrefix(url string) string {
if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
return "https://" + url
}
return url
}
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func init() {
panic(err)
}

//多语言
DefaultLang := config.String("quickclash.lang")
Languages := map[string]string{
"en": "English",
Expand Down Expand Up @@ -99,6 +100,8 @@ func main() {
color.BgLightBlue.Println(i18n.Dtr("inputSublink"))
fmt.Scanln(&SubUrl)
}
SubUrl = AddHTTPSPrefix(SubUrl)
fmt.Println(SubUrl)
os.Mkdir("yaml", os.ModePerm)
color.BgLightBlue.Println(i18n.Dtr("downloading", i18n.Dtr("configFile")))
err = Download(SubUrl, QuickClashSubYml)
Expand All @@ -113,6 +116,7 @@ func main() {
//加载配置文件
err = config.LoadFiles(QuickClashSubYml)
if err != nil {
os.Remove(QuickClashSubYml)
panic(err)
}

Expand Down

0 comments on commit afcae30

Please sign in to comment.