Skip to content

Commit

Permalink
fix search request detection, fix suggestion formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Jan 25, 2025
1 parent c6d2456 commit 3e570bd
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/app/browser/window/tab/item/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ fn lookup(
Ok(uri) => callback(feature, cancellable, Ok(uri)),
Err(_) => {
// try default scheme suggestion
let suggestion = format!("{DEFAULT_SCHEME}://{query}");
let suggestion = format!(
"{DEFAULT_SCHEME}://{}",
query
.strip_prefix(&format!("{DEFAULT_SCHEME}://"))
.unwrap_or(query)
);

let resolver = Resolver::default();
resolver.set_timeout(TIMEOUT);
Expand All @@ -161,22 +166,25 @@ fn lookup(
Ok(connectable) => resolver.lookup_by_name_async(
&connectable.hostname(),
Some(&cancellable.clone()),
move |resolve| {
callback(
feature,
cancellable,
if resolve.is_ok() {
match Uri::parse(&suggestion, UriFlags::NONE) {
Ok(uri) => Err(uri),
Err(_) => Err(search(&suggestion)),
}
} else {
Err(search(&suggestion))
},
)
{
let query = query.to_owned();
move |resolve| {
callback(
feature,
cancellable,
if resolve.is_ok() {
match Uri::parse(&suggestion, UriFlags::NONE) {
Ok(uri) => Err(uri),
Err(_) => Err(search(&query)),
}
} else {
Err(search(&query))
},
)
}
},
),
Err(_) => callback(feature, cancellable, Err(search(&suggestion))),
Err(_) => callback(feature, cancellable, Err(search(&query))),
}
}
}
Expand Down

0 comments on commit 3e570bd

Please sign in to comment.