summaryrefslogtreecommitdiff
path: root/lib/uRI.ml
diff options
context:
space:
mode:
authorยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2025-12-11 20:48:32 +0000
committerยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2025-12-11 20:48:32 +0000
commit0d7fa712f20bc02d20153e78704f59c89f8a5361 (patch)
tree5ddd51057085c787d48313d19777a4e28e1dc36f /lib/uRI.ml
parent4a5eecec6f54f2049d01e28ef220a98ef71f5896 (diff)
downloadnixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.tar
nixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.tar.gz
nixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.tar.bz2
nixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.tar.lz
nixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.tar.xz
nixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.tar.zst
nixtaml-0d7fa712f20bc02d20153e78704f59c89f8a5361.zip
add URI module
Diffstat (limited to 'lib/uRI.ml')
-rw-r--r--lib/uRI.ml24
1 files changed, 24 insertions, 0 deletions
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 <https://toast.al/contact/> โ”‚
+โ”‚ 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