Skip to content

Commit 5417acb

Browse files
authored
Merge pull request #64 from OlivierNicole/converge-jsoo-merge-01
Integrate ocsigen/js_of_ocaml#1497
2 parents 5b98a6f + 1540ceb commit 5417acb

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/js_of_ocaml/url.ml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,12 @@ module Current = struct
309309
else l##.search)
310310

311311
let get_fragment () =
312-
(* location.hash doesn't have the same behavior depending on the browser
313-
Firefox bug : https://bugzilla.mozilla.org/show_bug.cgi?id=483304 *)
314-
(* let s = Js.to_bytestring (l##hash) in *)
315-
(* if String.length s > 0 && s.[0] = '#' *)
316-
(* then String.sub s 1 (String.length s - 1) *)
317-
(* else s; *)
318-
Js.Opt.case
319-
(l##.href##_match (new%js Js.regExp (Js.string "#(.*)")))
320-
(fun () -> "")
321-
(fun res ->
322-
let res = Js.match_result res in
323-
Js.to_string (Js.Unsafe.get res 1))
324-
325-
let set_fragment s = l##.hash := Js.bytestring (urlencode s)
312+
let s = Js.to_bytestring l##.hash in
313+
if String.length s > 0 && Char.equal s.[0] '#'
314+
then String.sub s 1 (String.length s - 1)
315+
else s
316+
317+
let set_fragment s = l##.hash := Js.bytestring s
326318

327319
let get () = url_of_js_string l##.href
328320

0 commit comments

Comments
 (0)