Skip to content

Commit 4dbac09

Browse files
author
Bas De Bue
committed
Assume gemini:// for schemeless URLs in the omnibar
This somewhat arbitrarily requires schemeless URLs to contain at least one period and otherwise consist entirely of alphanumeric characters, to prevent false positives on regular search queries.
1 parent f1929cc commit 4dbac09

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/window.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,13 @@ impl Window {
360360
}
361361
fn open_omni(&self, v: &str) {
362362
let url = Url::parse(v)
363-
.or_else(|_| Url::parse(&format!("gemini://geminispace.info/search?{}", v)));
363+
.or_else(|_| {
364+
if v.contains(".") && v.split(".").all(|s| s.chars().all(char::is_alphanumeric)) {
365+
Url::parse(&format!("gemini://{}", v))
366+
} else {
367+
Url::parse(&format!("gemini://geminispace.info/search?{}", v))
368+
}
369+
});
364370
match url {
365371
Ok(url) => self.current_tab().spawn_open_url(url),
366372
Err(e) => error!("Failed to open from omni bar"),

0 commit comments

Comments
 (0)