diff --git a/src/soupault.ml b/src/soupault.ml index 868e7f0..c1c001a 100644 --- a/src/soupault.ml +++ b/src/soupault.ml @@ -132,7 +132,7 @@ let rec process_widgets settings env ws wh config soup = last parent if the page is an index page. *) let fix_nav_path settings path page_name = - if page_name = settings.index_page then Utils.safe_tl path + if page_name = settings.index_page then Utils.drop_tail path else path (* diff --git a/src/utils.ml b/src/utils.ml index 8fae3a5..1e98745 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -27,6 +27,9 @@ let safe_tl xs = | [] -> [] | _ :: xs' -> xs' +(** Removes the last element of a list *) +let drop_tail xs = List.rev xs |> safe_tl |> List.rev + (** Unsafely unwraps an option type. There are many places where None is easy to prove to not happen *) let unwrap_option o =