diff --git a/.changes/deep-link-android-pattern.md b/.changes/deep-link-android-pattern.md new file mode 100644 index 00000000..b3757125 --- /dev/null +++ b/.changes/deep-link-android-pattern.md @@ -0,0 +1,6 @@ +--- +deep-link: minor +deep-link-js: minor +--- + +Exposed Android's `path`, `pathPattern` and `pathSuffix` configurations. diff --git a/.changes/deep-link-android-scheme.md b/.changes/deep-link-android-scheme.md new file mode 100644 index 00000000..9d4ae694 --- /dev/null +++ b/.changes/deep-link-android-scheme.md @@ -0,0 +1,6 @@ +--- +deep-link: minor +deep-link-js: minor +--- + +Added a `scheme` configuration to set a scheme other than http/https. This is only supported on Android and will still default to http,https if not set. diff --git a/plugins/deep-link/build.rs b/plugins/deep-link/build.rs index 4bb909cb..418746b2 100644 --- a/plugins/deep-link/build.rs +++ b/plugins/deep-link/build.rs @@ -9,25 +9,50 @@ use config::{AssociatedDomain, Config}; const COMMANDS: &[&str] = &["get_current", "register", "unregister", "is_registered"]; // TODO: Consider using activity-alias in case users may have multiple activities in their app. -// TODO: Do we want to support the other path* configs too? fn intent_filter(domain: &AssociatedDomain) -> String { format!( r#" - - + {} {} + {} + {} + {} "#, + domain + .scheme + .iter() + .map(|scheme| format!(r#""#)) + .collect::>() + .join("\n "), domain.host, + domain + .path + .iter() + .map(|path| format!(r#""#)) + .collect::>() + .join("\n "), + domain + .path_pattern + .iter() + .map(|pattern| format!(r#""#)) + .collect::>() + .join("\n "), domain .path_prefix .iter() .map(|prefix| format!(r#""#)) .collect::>() - .join("\n ") + .join("\n "), + domain + .path_suffix + .iter() + .map(|suffix| format!(r#""#)) + .collect::>() + .join("\n "), ) } diff --git a/plugins/deep-link/src/config.rs b/plugins/deep-link/src/config.rs index d7bad5b4..88222a24 100644 --- a/plugins/deep-link/src/config.rs +++ b/plugins/deep-link/src/config.rs @@ -9,10 +9,25 @@ use tauri_utils::config::DeepLinkProtocol; #[derive(Deserialize, Clone)] pub struct AssociatedDomain { + #[serde(default = "default_schemes")] + pub scheme: Vec, + #[serde(deserialize_with = "deserialize_associated_host")] pub host: String, + + #[serde(default)] + pub path: Vec, + #[serde(default, alias = "path-pattern", rename = "pathPattern")] + pub path_pattern: Vec, #[serde(default, alias = "path-prefix", rename = "pathPrefix")] pub path_prefix: Vec, + #[serde(default, alias = "path-suffix", rename = "pathSuffix")] + pub path_suffix: Vec, +} + +// TODO: Consider removing this in v3 +fn default_schemes() -> Vec { + vec!["https".to_string(), "http".to_string()] } fn deserialize_associated_host<'de, D>(deserializer: D) -> Result