mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Clean code
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
7160aa8b3a
commit
64b4f38b21
1 changed files with 2 additions and 22 deletions
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue