mirror of
https://github.com/rclone/rclone.git
synced 2024-12-02 05:14:55 +01:00
24 lines
650 B
Go
24 lines
650 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"net/url"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// URLQueryEscape escapes the original string.
|
||
|
func URLQueryEscape(origin string) string {
|
||
|
escaped := url.QueryEscape(origin)
|
||
|
escaped = strings.Replace(escaped, "%2F", "/", -1)
|
||
|
escaped = strings.Replace(escaped, "%3D", "=", -1)
|
||
|
escaped = strings.Replace(escaped, "+", "%20", -1)
|
||
|
return escaped
|
||
|
}
|
||
|
|
||
|
// URLQueryUnescape unescapes the escaped string.
|
||
|
func URLQueryUnescape(escaped string) (string, error) {
|
||
|
escaped = strings.Replace(escaped, "/", "%2F", -1)
|
||
|
escaped = strings.Replace(escaped, "=", "%3D", -1)
|
||
|
escaped = strings.Replace(escaped, "%20", " ", -1)
|
||
|
return url.QueryUnescape(escaped)
|
||
|
}
|