mirror of
https://github.com/rclone/rclone.git
synced 2024-12-27 17:38:58 +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)
|
|
}
|