🎨 Clean code

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-11-09 15:41:51 +08:00
parent 7160aa8b3a
commit 64b4f38b21
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -33,21 +33,6 @@ import (
"github.com/siyuan-note/logging" "github.com/siyuan-note/logging"
) )
func ValidOptionalPort(port string) bool {
if port == "" {
return true
}
if port[0] != ':' {
return false
}
for _, b := range port[1:] {
if b < '0' || b > '9' {
return false
}
}
return true
}
func IsLocalHostname(hostname string) bool { func IsLocalHostname(hostname string) bool {
if "localhost" == hostname || strings.HasSuffix(hostname, ".localhost") { if "localhost" == hostname || strings.HasSuffix(hostname, ".localhost") {
return true return true
@ -67,8 +52,8 @@ func IsLocalHost(host string) bool {
} }
func IsLocalOrigin(origin string) bool { func IsLocalOrigin(origin string) bool {
if url, err := url.Parse(origin); err == nil { if u, err := url.Parse(origin); err == nil {
return IsLocalHostname(url.Hostname()) return IsLocalHostname(u.Hostname())
} }
return false return false
} }
@ -180,11 +165,6 @@ func InvalidIDPattern(idArg string, result *gulu.Result) bool {
return true return true
} }
func IsValidURL(str string) bool {
_, err := url.Parse(str)
return err == nil
}
func initHttpClient() { func initHttpClient() {
http.DefaultClient = httpclient.GetCloudFileClient2Min() http.DefaultClient = httpclient.GetCloudFileClient2Min()
http.DefaultTransport = httpclient.NewTransport(false) http.DefaultTransport = httpclient.NewTransport(false)