fix: parse query when there's a fragment indication

This commit is contained in:
Simon Cruanes 2024-02-28 15:01:13 -05:00
parent 179d41cd9a
commit 7e790c0161
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 7 additions and 0 deletions

View file

@ -76,6 +76,11 @@ let split_on_slash s : _ list =
List.rev !l
let parse_query s : (_ list, string) result =
let s =
match String.index_opt s '#' with
| Some i -> String.sub s (i + 1) (String.length s - i - 1)
| None -> s
in
let pairs = ref [] in
let is_sep_ = function
| '&' | ';' -> true

View file

@ -30,6 +30,8 @@ let () = assert_eq [] (U.split_on_slash "//")
let () =
assert_eq ~cmp:eq_sorted (Ok [ "a", "b"; "c", "d" ]) (U.parse_query "a=b&c=d")
let () = assert_eq (Ok [ "foo", "bar" ]) (U.parse_query "yolo#foo=bar")
let () =
add_qcheck
@@ QCheck.Test.make ~long_factor:20 ~count:1_000