Skip to content
29 linesCodeBlameRaw
1//! Where the window may go: the launcher, the server's pages, and the
2//! pages that sign someone in there. Any other address opens in the
3//! browser the system uses, and the window stays where it is.
4
5use tauri::AppHandle;
6use tauri_plugin_opener::OpenerExt;
7use url::Url;
8
9use crate::config;
10
11/// Signing in with GitHub goes there and comes back.
12const SIGN_IN_HOSTS: &[&str] = &["github.com", "www.github.com"];
13
14/// Whether the window may load `url`.
15pub fn allowed(app: &AppHandle, url: &Url) -> bool {
16 match url.scheme() {
17 "about" | "blob" | "data" => return true,
18 "http" | "https" | "tauri" => {}
19 _ => return false,
20 }
21 if config::is_launcher(url) || config::is_server(app, url) {
22 return true;
23 }
24 if url.host_str().is_some_and(|host| SIGN_IN_HOSTS.contains(&host)) {
25 return true;
26 }
27 let _ = app.opener().open_url(url.as_str(), None::<&str>);
28 false
29}