Skip to content

Commit 0f970e5

Browse files
committed
simplify parse_path
1 parent 9338f38 commit 0f970e5

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/implementation.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,10 @@ pub mod lambda_private {
9898
|| ct_lower.starts_with("application/x-www-form-urlencoded")
9999
}
100100

101-
/// Parse URL into path and query string parameters
102-
fn parse_url(url_str: &str) -> (String, HashMap<String, String>) {
103-
// Varnish typically provides just the path, so we need a base URL for parsing
104-
let full_url = if url_str.starts_with("http://") || url_str.starts_with("https://") {
105-
url_str.to_string()
106-
} else {
107-
format!("http://dummy{}", url_str)
108-
};
101+
/// Parse path into path and query string parameters
102+
fn parse_path(path_str: &str) -> (String, HashMap<String, String>) {
103+
// Varnish provides just the path, so we need a base URL for parsing
104+
let full_url = format!("http://dummy{}", path_str);
109105

110106
match Url::parse(&full_url) {
111107
Ok(url) => {
@@ -120,7 +116,7 @@ pub mod lambda_private {
120116
}
121117
Err(_) => {
122118
// Fallback to just the path if parsing fails
123-
(url_str.to_string(), HashMap::new())
119+
(path_str.to_string(), HashMap::new())
124120
}
125121
}
126122
}
@@ -526,7 +522,7 @@ pub mod lambda_private {
526522
let url = bereq.url()
527523
.map(|m| String::from_utf8_lossy(m.as_ref()).into_owned())
528524
.unwrap_or_else(|| "/".into());
529-
let (path, query_string_parameters) = parse_url(&url);
525+
let (path, query_string_parameters) = parse_path(&url);
530526

531527
// Extract headers
532528
let mut headers = HashMap::new();

0 commit comments

Comments
 (0)