go-gemini/query.go

20 lines
502 B
Go
Raw Normal View History

2020-11-27 20:26:22 -07:00
package gemini
import (
"net/url"
"strings"
)
2020-12-17 22:26:47 -07: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-27 20:26:22 -07:00
func QueryEscape(query string) string {
return strings.ReplaceAll(url.PathEscape(query), "+", "%2B")
}
2021-02-23 16:45:58 -07:00
// QueryUnescape unescapes a Gemini URL query.
// It is identical to url.PathUnescape.
2020-11-27 20:26:22 -07:00
func QueryUnescape(query string) (string, error) {
return url.PathUnescape(query)
}