Merge pull request 'use ignorelist to transmit the intention' (#105) from minor-wording into main

Reviewed-on: https://git.robur.io/robur/builder-web/pulls/105
This commit is contained in:
Reynir Björnsson 2022-04-22 11:20:01 +00:00
commit c72ff72e0d

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