Skip to content

Commit

Permalink
fix: url parse
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Dec 15, 2024
1 parent 1c1ca25 commit 61fc2a5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/deferred_data/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ impl HttpApi {
return HttpResponse::bad_request("expected GET method".to_string());
}

// convert URL to valid URL
let url = if req.url.starts_with("/") {
format!("http://localhost{}", req.url)
} else {
req.url.clone()
};
// parse url
let Ok(url) = Url::parse(&req.url) else {
return HttpResponse::bad_request("invalid URL".to_string());
let Ok(url) = Url::parse(&url) else {
return HttpResponse::bad_request(format!("Invalid URL: {url}"));
};

let mut router = Router::new();
Expand Down

0 comments on commit 61fc2a5

Please sign in to comment.