add query params to redirect

This commit is contained in:
Hannes Mehnert 2022-04-11 16:54:28 +02:00
parent 4c3a5986d6
commit 3bee8a357d

View file

@ -477,13 +477,18 @@ let add_routes datadir configdir =
in in
let redirect_parent req = let redirect_parent req =
let path = Dream.target req in
let parent = let parent =
Dream.target req |>
String.split_on_char '/' |> String.split_on_char '/' |>
List.rev |> List.tl |> List.rev |> List.rev |> List.tl |> List.rev |>
String.concat "/" String.concat "/"
in in
Dream.redirect ~status:`Temporary_Redirect req (parent ^ "/") let parent = parent ^ "/" in
let url = match Dream.queries req with
| [] -> parent
| xs -> parent ^ (Dream.to_form_urlencoded xs)
in
Dream.redirect ~status:`Temporary_Redirect req url
in in
let w f req = or_error_response (f req) in let w f req = or_error_response (f req) in