let remove_last_slash segs =
  let rec loop segs =
    match segs with | [] -> [] | [ "" ] -> [] | h :: t -> h :: (loop t)
  in loop segs