use ignorelist to transmit the intention

This commit is contained in:
Hannes Mehnert 2022-04-21 20:55:19 +02:00
parent 0f493e9b47
commit 6190347401

View file

@ -506,7 +506,7 @@ let add_routes ~datadir ~cachedir ~configdir =
Dream.post "/job/:job/platform/:platform/upload" (Authorization.authenticate (w upload_binary)); Dream.post "/job/:job/platform/:platform/upload" (Authorization.authenticate (w upload_binary));
] ]
let routeprefix_blacklist_when_removing_trailing_slash = [ let routeprefix_ignorelist_when_removing_trailing_slash = [
"/job/:job/build/:build/f" "/job/:job/build/:build/f"
] ]
@ -515,11 +515,11 @@ module Middleware = struct
let remove_trailing_url_slash : Dream.middleware = let remove_trailing_url_slash : Dream.middleware =
fun handler req -> fun handler req ->
let path = Dream.target req |> Utils.Path.of_url in let path = Dream.target req |> Utils.Path.of_url in
let is_blacklisted = let is_ignored =
routeprefix_blacklist_when_removing_trailing_slash routeprefix_ignorelist_when_removing_trailing_slash
|> List.exists (Utils.Path.matches_dreamroute ~path) |> List.exists (Utils.Path.matches_dreamroute ~path)
in in
if not (List.mem (Dream.method_ req) [`GET; `HEAD]) || is_blacklisted then if not (List.mem (Dream.method_ req) [`GET; `HEAD]) || is_ignored then
handler req handler req
else match List.rev path with else match List.rev path with
| "" :: [] (* / *) -> handler req | "" :: [] (* / *) -> handler req