parent
6137f53c38
commit
8f236f4832
@ -1,5 +1,5 @@
|
|||||||
package go_library
|
package go_library
|
||||||
|
|
||||||
func Version() string {
|
func Version() string {
|
||||||
return "1.0.148"
|
return "1.0.149"
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package gostring
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CompleteUrlHttp 补全 URL
|
||||||
|
func CompleteUrlHttp(url string) string {
|
||||||
|
if strings.HasPrefix(url, "//") {
|
||||||
|
url = "http:" + url
|
||||||
|
} else if strings.HasPrefix(url, "://") {
|
||||||
|
url = "http" + url
|
||||||
|
} else if strings.HasPrefix(url, "http://") {
|
||||||
|
} else if strings.HasPrefix(url, "https://") {
|
||||||
|
url = Replace(url, "https://", "http://")
|
||||||
|
} else {
|
||||||
|
url = "http://" + url
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompleteUrlHttps 补全 URL
|
||||||
|
func CompleteUrlHttps(url string) string {
|
||||||
|
if strings.HasPrefix(url, "//") {
|
||||||
|
url = "https:" + url
|
||||||
|
} else if strings.HasPrefix(url, "://") {
|
||||||
|
url = "https" + url
|
||||||
|
} else if strings.HasPrefix(url, "http://") {
|
||||||
|
url = Replace(url, "http://", "https://")
|
||||||
|
} else if strings.HasPrefix(url, "https://") {
|
||||||
|
} else {
|
||||||
|
url = "https://" + url
|
||||||
|
}
|
||||||
|
return url
|
||||||
|
}
|
Loading…
Reference in new issue