From c05d9ff300e82a6714271735db474664c7bd02ff Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Tue, 2 Jun 2020 14:33:21 -0400 Subject: Added to_canonical for mimetypes --- gemini/mimeType.ml | 6 ++++++ gemini/mimeType.mli | 2 ++ 2 files changed, 8 insertions(+) (limited to 'gemini') diff --git a/gemini/mimeType.ml b/gemini/mimeType.ml index 0cfd063..16abcab 100644 --- a/gemini/mimeType.ml +++ b/gemini/mimeType.ml @@ -11,6 +11,8 @@ sig val to_subtype : t -> string val to_parameter : t -> (string * string) option + + val to_canonical : t -> string end module MimeType : MIME_TYPE = @@ -62,4 +64,8 @@ struct let to_parameter m = m.mime_param + let to_canonical m = + match to_parameter m with + | Some (p, v) -> (to_type m) ^ "/" ^ (to_subtype m) ^ " " ^ p ^ "=" ^ v + | None -> (to_type m) ^ "/" ^ (to_subtype m) end diff --git a/gemini/mimeType.mli b/gemini/mimeType.mli index 6075ef9..c8b2959 100644 --- a/gemini/mimeType.mli +++ b/gemini/mimeType.mli @@ -11,6 +11,8 @@ sig val to_subtype : t -> string val to_parameter : t -> (string * string) option + + val to_canonical : t -> string end module MimeType : MIME_TYPE -- cgit v1.2.3