mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-11 08:12:26 +08:00
feat: add EncodeUrl function
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -157,3 +158,15 @@ func IsInternalIP(IP net.IP) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// EncodeUrl encode url
|
||||
func EncodeUrl(urlStr string) (string, error) {
|
||||
URL, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
URL.RawQuery = URL.Query().Encode()
|
||||
|
||||
return URL.String(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user