From 0d7fa712f20bc02d20153e78704f59c89f8a5361 Mon Sep 17 00:00:00 2001 From: ยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค Date: Thu, 11 Dec 2025 20:48:32 +0000 Subject: add URI module --- lib/uRI.ml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lib/uRI.ml (limited to 'lib/uRI.ml') diff --git a/lib/uRI.ml b/lib/uRI.ml new file mode 100644 index 0000000..cdcf9f5 --- /dev/null +++ b/lib/uRI.ml @@ -0,0 +1,24 @@ +(*โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ SPDX-FileCopyrightText: 2025 toastal โ”‚ +โ”‚ SPDX-License-Identifier: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€*) +(* extend & fix naming for ocaml-uri *) +include Uri + +let jsont : t Jsont.t = + Jsont.string + |> Jsont.map ~kind: "URI" ~dec: of_string ~enc: to_string + +(* good enough URI generation for now for this *) +let gen = + let open QCheck.Gen in + let a_to_z = (char_range 'a' 'z') in + let* scheme = QCheck.Gen.oneofl ["http"; "https"; "ftp"; "sftp"] in + let* host = string_size ~gen: a_to_z (int_bound 20) in + let* tld = string_size ~gen: a_to_z (int_bound 5) in + let* path_opt = option (string_size ~gen: a_to_z (int_bound 10)) in + let uri = + of_string @@ + Fmt.str "%s://%s.%s/%s" scheme host tld (Option.value ~default: "" path_opt) + in + return uri -- cgit v1.2.3