Skip to content

Commit

Permalink
Merge pull request ocaml-wasm#64 from OlivierNicole/converge-jsoo-mer…
Browse files Browse the repository at this point in the history
…ge-01

Integrate ocsigen/js_of_ocaml#1497
  • Loading branch information
vouillon authored Aug 22, 2024
2 parents 5b98a6f + 1540ceb commit 5417acb
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions lib/js_of_ocaml/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,12 @@ 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 set_fragment s = l##.hash := Js.bytestring (urlencode s)
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

let get () = url_of_js_string l##.href

Expand Down

0 comments on commit 5417acb

Please sign in to comment.