Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat: add URL normalization and deep link plugin integration
Tonhoaaa44256c3ee
diff --git a/src-tauri/src/external_url.rs b/src-tauri/src/external_url.rsindex c13b48b7..cecd276e 100644--- a/src-tauri/src/external_url.rs+++ b/src-tauri/src/external_url.rs@@ -44,15 +44,36 @@ pub fn is_external_url(value: &str) -> bool {return false;}- if trimmed.starts_with("magnet:") || trimmed.starts_with("p2p:") {+ let normalized = normalize_external_url(trimmed);+ let target: &str = normalized.as_deref().unwrap_or(trimmed);++ if target.starts_with("magnet:") || target.starts_with("p2p:") {return true;}- url::Url::parse(trimmed)+ url::Url::parse(target).map(|url| matches!(url.scheme(), "http" | "https")).unwrap_or(false)}+pub fn normalize_external_url(value: &str) -> Option<String> {+ let trimmed = value.trim();+ let rest = trimmed+ .strip_prefix("omniget://")+ .or_else(|| trimmed.strip_prefix("omniget:"))?;+ let rest = rest.trim_start_matches('/');+ if rest.is_empty() {+ return None;+ }+ if rest.starts_with("magnet:") || rest.starts_with("p2p:") {+ return Some(rest.to_string());+ }+ if rest.starts_with("http://") || rest.starts_with("https://") {+ return Some(rest.to_string());+ }+ Some(format!("https://{}", rest))+}+pub async fn queue_url_with_defaults(app: &AppHandle,url: String,@@ -267,6 +288,7 @@ pub async fn handle_external_url(url: String,source: &str,) -> Result<ExternalUrlAction, String> {+ let url = normalize_external_url(&url).unwrap_or(url);if !is_external_url(&url) {return Err("Invalid external URL".to_string());}@@ -326,6 +348,7 @@ whereargs.into_iter().map(|arg| arg.as_ref().trim().to_string()).find(|arg| is_external_url(arg))+ .map(|arg| normalize_external_url(&arg).unwrap_or(arg))}async fn push_or_emit_event(app: &AppHandle, event: ExternalUrlEvent) {diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 94f07401..a396b3bf 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -115,6 +115,7 @@ pub fn run() {.build(),).plugin(tauri_plugin_clipboard_manager::init())+ .plugin(tauri_plugin_deep_link::init()).setup(|app| {let settings = storage::config::load_settings(app.handle());core::http_client::init_proxy(settings.proxy.clone());