mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
fix: parse query when there's a fragment indication
This commit is contained in:
parent
179d41cd9a
commit
7e790c0161
2 changed files with 7 additions and 0 deletions
|
|
@ -76,6 +76,11 @@ let split_on_slash s : _ list =
|
||||||
List.rev !l
|
List.rev !l
|
||||||
|
|
||||||
let parse_query s : (_ list, string) result =
|
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 pairs = ref [] in
|
||||||
let is_sep_ = function
|
let is_sep_ = function
|
||||||
| '&' | ';' -> true
|
| '&' | ';' -> true
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ let () = assert_eq [] (U.split_on_slash "//")
|
||||||
let () =
|
let () =
|
||||||
assert_eq ~cmp:eq_sorted (Ok [ "a", "b"; "c", "d" ]) (U.parse_query "a=b&c=d")
|
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 () =
|
let () =
|
||||||
add_qcheck
|
add_qcheck
|
||||||
@@ QCheck.Test.make ~long_factor:20 ~count:1_000
|
@@ QCheck.Test.make ~long_factor:20 ~count:1_000
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue