💾 Archived View for gemi.dev › gemini-mailing-list › 000246.gmi captured on 2024-06-16 at 12:50:20. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-12-28)
-=-=-=-=-=-=-
Just wanted to let other Gemini Go coders know something about encoding query strings. The Gemini spec mandates percent coding, so you should be using url.PathEscape and url.PathUnescape to deal with queries, and NOT url.QueryEscape and url.QueryUnescape. However, there's one more thing. url.PathEscape does not replace + characters, although to ensure compatibility, it probably should. Here's the function I use in all my projects to escape queries: func pathEscape(path string) string { return strings.ReplaceAll(url.PathEscape(path), "+", "%2B") } This is simple, but seems to work perfectly. url.PathUnescape will still work fine for decoding. Cheers, makeworld
---