diff --git a/logarion.opam b/logarion.opam index 09b696a..e6fc486 100644 --- a/logarion.opam +++ b/logarion.opam @@ -14,7 +14,6 @@ depends: [ "uuidm" "omd" "opium" - "batteries" "lwt" "ptime" "re" diff --git a/src/core/meta.ml b/src/core/meta.ml index 65d8d3f..c11783f 100644 --- a/src/core/meta.ml +++ b/src/core/meta.ml @@ -88,16 +88,17 @@ let string_alias t = let is_reserved = function | '!' | '*' | '\'' | '(' | ')' | ';' | ':' | '@' | '&' | '=' | '+' | '$' | ',' | '/' | '?' | '#' | '[' | ']' | ' ' | '\t' | '\x00' -> true - | _ -> false in - let drop h t = t in - let dash h t = '-' :: t in - let rec filter fn = function - | [] -> [] - | head :: tail -> - if is_reserved head - then fn head (filter drop tail) - else Char.lowercase_ascii head :: (filter dash tail) in - Batteries.String.of_list @@ filter drop (Batteries.String.to_list t) + | _ -> false + in + let b = Buffer.create (String.length t) in + let filter char = + let open Buffer in + if is_reserved char + then (try (if nth b (pred (length b)) <> '-' then add_char b '-') with Invalid_argument _ -> prerr_endline "reserved") + else add_char b char + in + String.iter filter t; + Buffer.contents b type t = { title: string;