Skip to content

Commit dc6c892

Browse files
committed
Fix clippy collapsible if and format
1 parent b9aa597 commit dc6c892

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/api/providers.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ async fn prune_expired_browser_oauth_sessions() {
360360
}
361361

362362
fn resolve_browser_oauth_redirect_uri(headers: &HeaderMap) -> Option<String> {
363-
if let Some(origin) = header_value(headers, axum::http::header::ORIGIN.as_str()) {
364-
if let Ok(origin_url) = Url::parse(origin) {
365-
let origin = origin_url.origin().ascii_serialization();
366-
if origin != "null" {
367-
return Some(format!("{origin}{OPENAI_BROWSER_OAUTH_REDIRECT_PATH}"));
368-
}
363+
if let Some(origin) = header_value(headers, axum::http::header::ORIGIN.as_str())
364+
&& let Ok(origin_url) = Url::parse(origin)
365+
{
366+
let origin = origin_url.origin().ascii_serialization();
367+
if origin != "null" {
368+
return Some(format!("{origin}{OPENAI_BROWSER_OAUTH_REDIRECT_PATH}"));
369369
}
370370
}
371371

@@ -382,7 +382,11 @@ fn resolve_browser_oauth_redirect_uri(headers: &HeaderMap) -> Option<String> {
382382

383383
if let Some(host) = header_value(headers, "host") {
384384
let host = normalize_host(host);
385-
let scheme = if is_local_host(&host) { "http" } else { "https" };
385+
let scheme = if is_local_host(&host) {
386+
"http"
387+
} else {
388+
"https"
389+
};
386390
return Some(format!(
387391
"{scheme}://{host}{OPENAI_BROWSER_OAUTH_REDIRECT_PATH}"
388392
));
@@ -392,7 +396,9 @@ fn resolve_browser_oauth_redirect_uri(headers: &HeaderMap) -> Option<String> {
392396
}
393397

394398
fn header_value(headers: &HeaderMap, name: impl AsRef<str>) -> Option<&str> {
395-
headers.get(name.as_ref()).and_then(|value| value.to_str().ok())
399+
headers
400+
.get(name.as_ref())
401+
.and_then(|value| value.to_str().ok())
396402
}
397403

398404
fn first_header_value(value: &str) -> &str {

0 commit comments

Comments
 (0)