Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ All notable changes to Tarn are documented in this file. The format is based on

### Fixed

- A single word with non-ASCII letters, such as `übersetzer`, is searched for instead of opened as
a site named `xn--bersetzer-p9a`.
- Retry and Reload now work on a tab whose first page never loaded (for example a router's page
that fails under Strict's HTTPS-only rule); they did nothing and left a blank page, also after
the site was set to Standard.
Expand Down
13 changes: 9 additions & 4 deletions crates/browser-core/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,9 @@ fn host_like(input: &str) -> Option<Url> {
if host == "localhost" || host.ends_with(".localhost") || bare.parse::<IpAddr>().is_ok() {
return Some(local);
}
let tld = host.rsplit('.').next()?;
let has_tld = host.contains('.') && tld.len() >= 2 && tld.chars().all(|c| c.is_ascii_alphabetic());
let punycode_tld = tld.starts_with("xn--");
(has_tld || punycode_tld).then(|| Url::parse(&format!("https://{input}")).ok())?
let (_, tld) = host.rsplit_once('.')?;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let has_tld = (tld.len() >= 2 && tld.chars().all(|c| c.is_ascii_alphabetic())) || tld.starts_with("xn--");
has_tld.then(|| Url::parse(&format!("https://{input}")).ok())?
}

pub const GLYPHS: &[(&str, &str)] = &[
Expand Down Expand Up @@ -605,6 +604,7 @@ mod tests {
assert_eq!(nav("app.localhost:5173"), "http://app.localhost:5173/");
assert_eq!(nav("example.com:8443/x"), "https://example.com:8443/x");
assert_eq!(nav("münchen.de"), "https://xn--mnchen-3ya.de/");
assert_eq!(nav("пример.рф"), "https://xn--e1afmkfd.xn--p1ai/");
assert_eq!(nav("about:blank"), "about:blank");
}

Expand All @@ -629,6 +629,11 @@ mod tests {
assert!(matches!(kind("rust lifetimes"), Some(Input::Search(_))));
assert!(matches!(kind("re:invent"), Some(Input::Search(_))));
assert!(matches!(kind("hello"), Some(Input::Search(_))));
assert!(matches!(kind("übersetzer"), Some(Input::Search(_))));
assert!(matches!(kind("xn--bersetzer-p9a"), Some(Input::Search(_))));
for s in ["intranet:3000/x", "übersetzer:3000/x", "xn--bersetzer-p9a:3000/x"] {
assert!(matches!(kind(s), Some(Input::Search(_))), "{s}");
}
assert!(matches!(kind("what is a.b"), Some(Input::Search(_))));
assert!(matches!(kind("mailto:a@example.com"), Some(Input::External(_))));
assert_eq!(kind(" "), None);
Expand Down
Loading