From 902e30d309ceceff1ace4a16da845eff6128fe24 Mon Sep 17 00:00:00 2001 From: Swrup Date: Thu, 19 Mar 2026 19:55:53 +0100 Subject: [PATCH] fmt+add deps --- .ocamlformat | 2 +- clear_url.opam | 16 +++++++++++++--- dune-project | 30 +++++++++++++++++------------- src/clear_url.ml | 17 +++++++---------- 4 files changed, 38 insertions(+), 27 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index cc34f68..6f010c4 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,4 +1,4 @@ -version=0.20.1 +version=0.28.1 assignment-operator=end-line break-cases=fit break-fun-decl=wrap diff --git a/clear_url.opam b/clear_url.opam index 5c62a76..8796833 100644 --- a/clear_url.opam +++ b/clear_url.opam @@ -2,14 +2,24 @@ opam-version: "2.0" synopsis: "OCaml library to remove tracking in URLs" description: "Use `Clear_url.clean` to remove tracking elements from URLs." +maintainer: ["swrup "] authors: ["swrup "] license: "ISC" tags: ["clear_url" "clean" "url" "tracker" "web3"] -homepage: "https://git.zapashcanon.fr/swrup/clear-url" -bug-reports: "https://git.zapashcanon.fr/swrup/ocaml-clear-url/issues" +homepage: "https://forge.kumikode.org/swrup/clear-url" +bug-reports: "https://forge.kumikode.org/swrup/clear-url/issues" depends: [ "dune" {>= "2.9"} "ocaml" {>= "4.08"} + "bos" + "fpath" + "re" + "uri" + "yojson" + "lwt" {with-dev-setup} + "tls-lwt" {with-dev-setup} + "cohttp-lwt" {with-dev-setup} + "cohttp-lwt-unix" {with-dev-setup} "odoc" {with-doc} ] build: [ @@ -28,4 +38,4 @@ build: [ ] ["dune" "install" "-p" name "--create-install-files" name] ] -dev-repo: "git+https://git.zapashcanon.fr/swrup/clear-url.git" +dev-repo: "git+https://forge.kumikode.org/swrup/clear-url.git" diff --git a/dune-project b/dune-project index b6e3de7..abce7b0 100644 --- a/dune-project +++ b/dune-project @@ -1,21 +1,16 @@ (lang dune 2.9) - +(name clear_url) +(generate_opam_files true) (implicit_transitive_deps false) -(name clear_url) - +(authors "swrup ") +(maintainers "swrup ") (license ISC) -(authors "swrup ") - (source - (uri git+https://git.zapashcanon.fr/swrup/clear-url.git)) - -(homepage https://git.zapashcanon.fr/swrup/clear-url) - -(bug_reports https://git.zapashcanon.fr/swrup/ocaml-clear-url/issues) - -(generate_opam_files true) + (uri git+https://forge.kumikode.org/swrup/clear-url.git)) +(homepage https://forge.kumikode.org/swrup/clear-url) +(bug_reports https://forge.kumikode.org/swrup/clear-url/issues) (package (name clear_url) @@ -26,4 +21,13 @@ (clear_url clean url tracker web3)) (depends (ocaml - (>= 4.08)))) + (>= 4.08)) + bos + fpath + re + uri + yojson + (lwt :with-dev-setup) + (tls-lwt :with-dev-setup) + (cohttp-lwt :with-dev-setup) + (cohttp-lwt-unix :with-dev-setup))) diff --git a/src/clear_url.ml b/src/clear_url.ml index a26e282..d8d6e6c 100644 --- a/src/clear_url.ml +++ b/src/clear_url.ml @@ -30,11 +30,11 @@ let regexps_array = let get_array key = value |> (fun el -> - (*we can't use `filter_member "rules"` here because empty list - * where removed from the file ..*) - match member key el with - | `Null -> (*it was an empty list *) [] - | json -> to_list json ) + (*we can't use `filter_member "rules"` here because empty list + * where removed from the file ..*) + match member key el with + | `Null -> (*it was an empty list *) [] + | json -> to_list json ) |> filter_string |> Array.of_list in let compile_array l = @@ -62,8 +62,7 @@ let clean url = let regexps_list = Array.fold_left (fun acc regexps -> - if Re.matches regexps.urlpattern url <> [] then regexps :: acc else acc - ) + if Re.matches regexps.urlpattern url <> [] then regexps :: acc else acc ) [] regexps_array in @@ -74,9 +73,7 @@ let clean url = regexps_list in if is_exception then url - else - (*TODO implement redirection, is it always percent-encoded ?? *) - + else (*TODO implement redirection, is it always percent-encoded ?? *) (* apply rawrules to whole url *) let url = List.fold_left