Skip to content

Commit 952d2d6

Browse files
fixes ensure_backend_from_url() to excract origin host name correctly
1 parent 215fc84 commit 952d2d6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

crates/common/src/backend.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ pub fn ensure_backend_from_url(origin_url: &str) -> Result<String, Report<Truste
7373
})?;
7474

7575
let scheme = parsed_url.scheme();
76-
let host = parsed_url.host_str().ok_or_else(|| {
77-
Report::new(TrustedServerError::Proxy {
78-
message: "Missing host in origin_url".to_string(),
76+
let host = Url::parse(origin_url)
77+
.ok()
78+
.and_then(|url| {
79+
url.host_str().map(|host| match url.port() {
80+
Some(port) => format!("{}:{}", host, port),
81+
None => host.to_string(),
82+
})
7983
})
80-
})?;
84+
.unwrap_or_else(|| origin_url.to_string());
8185
let port = parsed_url.port();
8286

83-
ensure_origin_backend(scheme, host, port)
87+
ensure_origin_backend(scheme, &host, port)
8488
}
8589

8690
#[cfg(test)]

0 commit comments

Comments
 (0)