On the use of %20 instead of + in URIs

colecmac at protonmail.com colecmac at protonmail.com
Fri Nov 27 18:30:43 GMT 2020


(My initial email only went to Adnan, sorry.)


> The Go URL library encodes spaces in the query string as '+'. Is this
> correct behavior?

Not for Gemini, no. According to RFCs it is okay, I believe. Whether or
not this should be changed, here's how my go-gemini library handles it.
These funcs should be used in place of the "net/url" ones.


func QueryEscape(query string) string {
    return strings.ReplaceAll(url.PathEscape(query), "+", "%2B")
}


func QueryUnescape(query string) (string, error) {
    return url.PathUnescape(query)
}



I hope that's helpful.


makeworld


More information about the Gemini mailing list