Skip to content

Commit

Permalink
Playground: upgrade brr to 0.0.6 to fix URI param hack (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-max authored Aug 22, 2023
1 parent f8d963a commit 1c51276
Show file tree
Hide file tree
Showing 6 changed files with 27,881 additions and 27,615 deletions.
6,955 changes: 3,539 additions & 3,416 deletions playground/asset/merlin.min.js

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions playground/asset/playground.min.js

Large diffs are not rendered by default.

48,460 changes: 24,304 additions & 24,156 deletions playground/asset/worker.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions playground/dune-project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(lang dune 3.0)

(using directory-targets 0.1)
(using directory-targets 0.1)

(name ocamlorg-playground)

Expand Down Expand Up @@ -35,7 +35,8 @@
(depends
(ocaml
(>= 5.0.0))
brr
(brr
(>= 0.0.6))
esbuild
(js_of_ocaml
(>= 5.0))
Expand Down
2 changes: 1 addition & 1 deletion playground/ocamlorg-playground.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bug-reports: "https://github.com/ocaml/ocaml.org/issues"
depends: [
"dune" {>= "3.0"}
"ocaml" {>= "5.0.0"}
"brr"
"brr" {>= "0.0.6"}
"esbuild"
"js_of_ocaml" {>= "5.0"}
"js-top-worker"
Expand Down
10 changes: 2 additions & 8 deletions playground/src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ module Codec = struct

let from_window () =
let uri = Window.location G.window in
(* Bypass double encoding (dbuenzli/brr/issues/50) *)
let fragment = Jv.get (Uri.to_jv uri) "hash" |> Jv.to_jstr in
let params = Uri.Params.of_jstr (fragment |> Jstr.slice ~start:1) in
let params = Uri.fragment_params uri in
let from_code jstr =
(* previously, '+' was not URL-encoded and thus became ' ' *)
let unspace = replace ~find:(Jstr.v " ") ~replace:(Jstr.v "+") jstr in
Expand All @@ -134,11 +132,7 @@ module Codec = struct
let data = Base64.data_utf_8_of_jstr s in
let+ bin = Base64.encode data in
let query = Uri.Params.of_assoc [ (Jstr.v "code", bin) ] in
let uri = Window.location G.window in
(* Bypass double encoding (dbuenzli/brr/issues/50); consider that without
the bypass it would be impossible to place the string '%2B' (encoding of
'+') in the URI *)
Jv.set (Uri.to_jv uri) "hash" (Uri.Params.to_jv query);
let uri = Uri.with_fragment_params (Window.location G.window) query in
Window.set_location G.window uri;
Ok ()
end
Expand Down

0 comments on commit 1c51276

Please sign in to comment.