···8282 |> List.rev
8383 |> List.filter (fun s -> s <> "")
8484 |> List.map (fun label ->
8585- match Punycode.encode_label label with
8686- | Ok encoded -> String.lowercase_ascii encoded
8787- | Error _ -> String.lowercase_ascii label)
8585+ try String.lowercase_ascii (Punycode.encode_label label)
8686+ with Punycode.Error _ -> String.lowercase_ascii label)
8887 in
8988 if labels = [] then None else Some { labels; rule_type; section }
9089
+6-3
lib/publicsuffix.ml
···152152 if domain = "" then Error Empty_domain
153153 else
154154 (* Convert IDN to ASCII (Punycode) *)
155155- match Punycode_idna.to_ascii domain with
156156- | Error e ->
157157- let msg = Format.asprintf "%a" Punycode_idna.pp_error e in
155155+ match
156156+ try Ok (Punycode_idna.to_ascii domain)
157157+ with Punycode_idna.Error e ->
158158+ let msg = Format.asprintf "%a" Punycode_idna.pp_error_reason e in
158159 Error (Punycode_error msg)
160160+ with
161161+ | Error e -> Error e
159162 | Ok ascii_domain ->
160163 (* Convert to lowercase and split into labels *)
161164 let ascii_lower = String.lowercase_ascii ascii_domain in