Skip to content

Commit

Permalink
Fix query return value when there are no values are passed.
Browse files Browse the repository at this point in the history
Fix query return value when only a keyword is passed for the key-value pair.
  • Loading branch information
patchgamestudio committed Jan 3, 2022
1 parent 79f461e commit 77e39c7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,14 @@ async fn index(
mut payload: web::Payload,
req: HttpRequest,
) -> impl Responder {
let split = req.query_string().split("&");
let mut queries = HashMap::new();
for s in split {
let params = s.split_once("=").unwrap_or(("", ""));
queries.insert(params.0, params.1);

if req.query_string().len() > 0 {
let split = req.query_string().split("&");
for s in split {
let params = s.split_once("=").unwrap_or((s, ""));
queries.insert(params.0, params.1);
}
}

match router.get_route(req.method().clone(), req.uri().path()) {
Expand Down

0 comments on commit 77e39c7

Please sign in to comment.