Fork me on GitHub
#reitit
<
2022-09-10
>
Eugen21:09:02

this might sound noobish, but is there a way to build web paths in a "portable" way ? Right now I use str but I noticed it failed when I added (ring/redirect-trailing-slash-handler) . This is because I had "/clicked" and after rediect-handler I had "//clicked" .

(defn home [request]
  (let [{:keys [uri]} request
        clicked-path (str uri "clicked")]
    (page   
     [:body
      [:h1 "Welcome to Htmx + Kit module"]
      [:button {:hx-post clicked-path :hx-swap "outerHTML"} "Click me!"]])))
Is there an utility that can build paths from parts like for filesystem e.g. https://babashka.org/fs/API.html#path ?

rolt09:09:44

it feels like it's overkill but there's https://github.com/lambdaisland/uri

Eugen09:09:05

thanks, the library looks nice . I will check it out