1
0
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:
dudaodong
2022-07-15 16:29:41 +08:00
parent 47ecfbfd5f
commit 506a8b4776
2 changed files with 26 additions and 0 deletions

View File

@@ -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
}