Skip to content

Commit 68b1bfa

Browse files
committed
fix(core-rs): initialize candidate directly to satisfy clippy
1 parent 7487c83 commit 68b1bfa

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

apps/headless-rs/src/url.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,12 @@ pub fn normalized_web_url(input: &str) -> Result<Url, ValidationError> {
104104
}
105105

106106
let lower = trimmed.to_ascii_lowercase();
107-
let candidate: String;
108-
if lower.starts_with("http://") || lower.starts_with("https://") {
109-
candidate = trimmed.to_string();
107+
let candidate: String = if lower.starts_with("http://") || lower.starts_with("https://") {
108+
trimmed.to_string()
110109
} else if trimmed.contains("://") {
111110
return Err(ValidationError::InvalidUrl(input.to_string()));
112111
} else if is_local_development_address(trimmed) {
113-
candidate = format!("http://{trimmed}");
112+
format!("http://{trimmed}")
114113
} else {
115114
// Reject explicit non-web schemes such as javascript:, data:, and
116115
// mailto:. A colon followed by digits is retained as a normal port.
@@ -119,8 +118,8 @@ pub fn normalized_web_url(input: &str) -> Result<Url, ValidationError> {
119118
return Err(ValidationError::InvalidUrl(input.to_string()));
120119
}
121120
}
122-
candidate = format!("https://{trimmed}");
123-
}
121+
format!("https://{trimmed}")
122+
};
124123

125124
let url = Url::parse(&candidate).ok_or_else(|| ValidationError::InvalidUrl(input.to_string()))?;
126125
if !is_web_navigation_url(&url) {

0 commit comments

Comments
 (0)