Skip to content

Commit ba58e19

Browse files
committed
Handle //
1 parent 7924ded commit ba58e19

File tree

1 file changed

+12
-3
lines changed
  • lib/dsc-lib/src/functions

1 file changed

+12
-3
lines changed

lib/dsc-lib/src/functions/uri.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,20 @@ fn combine_uri(base_uri: &str, relative_uri: &str) -> Result<String, DscError> {
5050
}
5151

5252
if relative_uri.starts_with("//") {
53-
if let Some(scheme_end) = base_uri.find("://") {
54-
let scheme = &base_uri[..scheme_end];
53+
// Protocol-relative URI: extract scheme from base
54+
let scheme = if let Some(scheme_end) = base_uri.find("://") {
55+
&base_uri[..scheme_end]
56+
} else {
57+
"https"
58+
};
59+
60+
// Check if the protocol-relative URI has a path
61+
let uri_without_slashes = &relative_uri[2..]; // Remove leading //
62+
if uri_without_slashes.contains('/') {
63+
// Has a path, use as-is
5564
return Ok(format!("{scheme}:{relative_uri}"));
5665
}
57-
return Ok(format!("https:{relative_uri}"));
66+
return Ok(format!("{scheme}:{relative_uri}/"));
5867
}
5968

6069
let base_ends_with_slash = base_uri.ends_with('/');

0 commit comments

Comments
 (0)