2020-11-28 04:26:22 +01:00
|
|
|
package gemini
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2020-12-18 06:26:47 +01:00
|
|
|
// QueryEscape escapes a string for use in a Gemini URL query.
|
|
|
|
// It is like url.PathEscape except that it also replaces plus signs
|
|
|
|
// with their percent-encoded counterpart.
|
2020-11-28 04:26:22 +01:00
|
|
|
func QueryEscape(query string) string {
|
|
|
|
return strings.ReplaceAll(url.PathEscape(query), "+", "%2B")
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryUnescape is identical to url.PathUnescape.
|
|
|
|
func QueryUnescape(query string) (string, error) {
|
|
|
|
return url.PathUnescape(query)
|
|
|
|
}
|