From e9956d608bdf9ce3a6c15ad30619f1317c42bac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8jberg?= Date: Thu, 5 Dec 2024 15:05:37 -0500 Subject: [PATCH] Guard against how Browsers encode spaces When using the Browser's address bar to perform a search on Share it uses `+` instead of `%20` to encode spaces and this ends up as literal `+` when parsed with `Url.percentDecode`. To solve this, replace all `+` with `%20%` before calling `Url.percentDecode`. Note: this will still work for search queries where the user wants to find "+", which is encoded by `Url.percentEncode` as `%2b`. --- src/UnisonShare/App.elm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/UnisonShare/App.elm b/src/UnisonShare/App.elm index dc5e191f..86c1cde8 100644 --- a/src/UnisonShare/App.elm +++ b/src/UnisonShare/App.elm @@ -106,6 +106,11 @@ init appContext route = search = Parser.parse (Parser.query (Query.string "search")) url |> Maybe.withDefault Nothing + -- When using the Browser's address bar to + -- perform a search on Share it uses + instead + -- of %20 to encode spaces and this ends up as + -- literal + when parsed with Url.percentDecode + |> Maybe.map (String.replace "+" "%20") |> Maybe.andThen Url.percentDecode filter =