From 79045898134e9b1d9c67a2b8d220a3fcced1b194 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Wed, 21 Aug 2024 17:53:02 +0200 Subject: [PATCH] Redirectmod: removing deprecated (and ambiguous) regexp option --- src/extensions/redirectmod.ml | 34 ++++++++-------------------------- src/extensions/redirectmod.mli | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/extensions/redirectmod.ml b/src/extensions/redirectmod.ml index 1c65647fd..8c5fdcc43 100644 --- a/src/extensions/redirectmod.ml +++ b/src/extensions/redirectmod.ml @@ -26,30 +26,15 @@ let section = Lwt_log.Section.make "ocsigen:ext:redirectmod" (* The table of redirections for each virtual server *) type redirection = - { r_regexp : Pcre.regexp - ; r_dest : string - ; r_full : [`Yes | `No | `Maybe] - ; r_temp : bool } + {r_regexp : Pcre.regexp; r_dest : string; r_full : bool; r_temp : bool} -let create_redirection ?(full_url = `Yes) ?(temporary = false) ~regexp r_dest = +let create_redirection ?(full_url = true) ?(temporary = false) ~regexp r_dest = let r_regexp = Pcre.regexp ("^" ^ regexp ^ "$") in - { r_regexp - ; r_dest - ; r_full = (full_url :> [`Yes | `No | `Maybe]) - ; r_temp = temporary } + {r_regexp; r_dest; r_full = full_url; r_temp = temporary} let attempt_redir {r_regexp; r_dest; r_full; r_temp} _err ri () = Lwt_log.ign_info ~section "Is it a redirection?"; - let redir = - let find full = - Ocsigen_extensions.find_redirection r_regexp full r_dest ri - in - match r_full with - | `Yes -> find true - | `No -> find false - | `Maybe -> ( - try find false with Ocsigen_extensions.Not_concerned -> find true) - in + let redir = Ocsigen_extensions.find_redirection r_regexp r_full r_dest ri in Lwt_log.ign_info_f ~section "YES! %s redirection to: %s" (if r_temp then "Temporary " else "Permanent ") redir; @@ -76,7 +61,7 @@ let gen dir = function let parse_config config_elem = let regexp = ref None and dest = ref "" - and mode = ref `Yes + and mode = ref true and temporary = ref false in Ocsigen_extensions.( Configuration.process_element ~in_tag:"host" @@ -84,15 +69,12 @@ let parse_config config_elem = ~elements: [ Configuration.element ~name:"redirect" ~attributes: - [ Configuration.attribute ~name:"regexp" (fun s -> - regexp := Some ("^" ^ s ^ "$"); - mode := `Maybe) - ; Configuration.attribute ~name:"fullurl" (fun s -> + [ Configuration.attribute ~name:"fullurl" (fun s -> regexp := Some s; - mode := `Yes) + mode := true) ; Configuration.attribute ~name:"suburl" (fun s -> regexp := Some s; - mode := `No) + mode := false) ; Configuration.attribute ~name:"dest" ~obligatory:true (fun s -> dest := s) ; Configuration.attribute ~name:"temporary" (function diff --git a/src/extensions/redirectmod.mli b/src/extensions/redirectmod.mli index 18465ee2b..9161538be 100644 --- a/src/extensions/redirectmod.mli +++ b/src/extensions/redirectmod.mli @@ -18,7 +18,7 @@ val section : Lwt_log_core.section type redirection val create_redirection : - ?full_url:[< `Maybe | `No | `Yes > `Yes] + ?full_url:bool -> ?temporary:bool -> regexp:string -> string