From b32253d57383354028ced754c013e779246b9d95 Mon Sep 17 00:00:00 2001 From: Erik Martin-Dorel Date: Fri, 28 Jul 2023 00:20:11 +0200 Subject: [PATCH 1/3] fix(url.ml): set_fragment need not any urlencode --- lib/js_of_ocaml/url.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/js_of_ocaml/url.ml b/lib/js_of_ocaml/url.ml index 1be4dfe656..eb2312222e 100644 --- a/lib/js_of_ocaml/url.ml +++ b/lib/js_of_ocaml/url.ml @@ -322,7 +322,7 @@ module Current = struct let res = Js.match_result res in Js.to_string (Js.Unsafe.get res 1)) - let set_fragment s = l##.hash := Js.bytestring (urlencode s) + let set_fragment s = l##.hash := Js.bytestring s let get () = url_of_js_string l##.href From 0c7ed715c1e88f737328e39d014dde23ad19eb68 Mon Sep 17 00:00:00 2001 From: Erik Martin-Dorel Date: Wed, 2 Aug 2023 15:39:32 +0200 Subject: [PATCH 2/3] fix(url.ml): Simplify get_fragment as well and directly use l##.hash; given Firefox' bug https://bugzilla.mozilla.org/show_bug.cgi?id=483304 is closed since 8+ years. --- lib/js_of_ocaml/url.ml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/js_of_ocaml/url.ml b/lib/js_of_ocaml/url.ml index eb2312222e..a9791f34ef 100644 --- a/lib/js_of_ocaml/url.ml +++ b/lib/js_of_ocaml/url.ml @@ -309,18 +309,10 @@ module Current = struct else l##.search) let get_fragment () = - (* location.hash doesn't have the same behavior depending on the browser - Firefox bug : https://bugzilla.mozilla.org/show_bug.cgi?id=483304 *) - (* let s = Js.to_bytestring (l##hash) in *) - (* if String.length s > 0 && s.[0] = '#' *) - (* then String.sub s 1 (String.length s - 1) *) - (* else s; *) - Js.Opt.case - (l##.href##_match (new%js Js.regExp (Js.string "#(.*)"))) - (fun () -> "") - (fun res -> - let res = Js.match_result res in - Js.to_string (Js.Unsafe.get res 1)) + let s = Js.to_bytestring l##.hash in + if String.length s > 0 && Char.equal s.[0] '#' + then String.sub s 1 (String.length s - 1) + else s let set_fragment s = l##.hash := Js.bytestring s From f7a1a292998d2f205c9b6e0cf463a605bb650d74 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Sat, 11 Nov 2023 22:15:52 +0100 Subject: [PATCH 3/3] Changes --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index c6e915e9b6..e4ba5c770b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,6 +19,7 @@ * Compiler: fix free variables pass wrt parameters' default value (#1521) * Compiler: fix free variables for classes * Compiler: fix internal invariant (continuation) +* Lib: Url.Current.set_fragment need not any urlencode (#1497) # 5.4.0 (2023-07-06) - Lille