Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| preparing for cloud work | 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 | ||
| 5 | use tauri::AppHandle; | |
| 6 | use tauri_plugin_opener::OpenerExt; | |
| 7 | use url::Url; | |
| 8 | ||
| 9 | use crate::config; | |
| 10 | ||
| 11 | /// Signing in with GitHub goes there and comes back. | |
| 12 | const SIGN_IN_HOSTS: &[&str] = &["github.com", "www.github.com"]; | |
| 13 | ||
| 14 | /// Whether the window may load `url`. | |
| 15 | pub 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 | } |