File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ val encode_arguments : (string * string) list -> string
7777
7878val decode_arguments : string -> (string * string ) list
7979(* * [decode_arguments s] parses [s] returning the sliced-diced
80- association list. *)
80+ association list. [s] should be only the arguments part (after the '?')
81+ not the whole url. *)
8182
8283(* * The following part allow one to handle Url object in a much higher level
8384 than what a string provides. *)
Original file line number Diff line number Diff line change @@ -39,3 +39,20 @@ let%expect_test _ =
3939 then ()
4040 else print_endline " escaping error" ;
4141 [% expect {|| }]
42+
43+ let % expect_test " [decode_arguments]" =
44+ let test url =
45+ ListLabels. iter (Url. decode_arguments url) ~f: (fun (key , value ) ->
46+ Printf. printf " '%s' => '%s'\n " key value)
47+ in
48+ (* Incorrect usage: passing in full url. *)
49+ test " https://foo.com/?foo=bar&baz%20=qux%22quux" ;
50+ [% expect {|
51+ 'https :// foo.com/? foo' => 'bar '
52+ 'baz ' => 'qux "quux' |}];
53+ (* correct usage: only the arguments part *)
54+ test " foo= bar& baz% 20 = qux% 22 quux";
55+ [%expect {|
56+ 'foo' => 'bar'
57+ 'baz ' => 'qux" quux' |}];
58+ ignore ()
You can’t perform that action at this time.
0 commit comments