mirror of
https://git.sr.ht/~adnano/go-gemini
synced 2024-12-04 09:18:17 +01:00
19 lines
466 B
Go
19 lines
466 B
Go
package gemini
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// 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.
|
|
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)
|
|
}
|