Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/deep-link-android-pattern.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
deep-link: minor
deep-link-js: minor
---

Exposed Android's `path`, `pathPattern` and `pathSuffix` configurations.
6 changes: 6 additions & 0 deletions .changes/deep-link-android-scheme.md
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 29 additions & 4 deletions plugins/deep-link/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
{}
<data android:host="{}" />
{}
{}
{}
{}
</intent-filter>"#,
domain
.scheme
.iter()
.map(|scheme| format!(r#"<data android:scheme="{scheme}" />"#))
.collect::<Vec<_>>()
.join("\n "),
domain.host,
domain
.path
.iter()
.map(|path| format!(r#"<data android:path="{path}" />"#))
.collect::<Vec<_>>()
.join("\n "),
domain
.path_pattern
.iter()
.map(|pattern| format!(r#"<data android:pathPattern="{pattern}" />"#))
.collect::<Vec<_>>()
.join("\n "),
domain
.path_prefix
.iter()
.map(|prefix| format!(r#"<data android:pathPrefix="{prefix}" />"#))
.collect::<Vec<_>>()
.join("\n ")
.join("\n "),
domain
.path_suffix
.iter()
.map(|suffix| format!(r#"<data android:pathSuffix="{suffix}" />"#))
.collect::<Vec<_>>()
.join("\n "),
)
}

Expand Down
15 changes: 15 additions & 0 deletions plugins/deep-link/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@ use tauri_utils::config::DeepLinkProtocol;

#[derive(Deserialize, Clone)]
pub struct AssociatedDomain {
#[serde(default = "default_schemes")]
pub scheme: Vec<String>,

#[serde(deserialize_with = "deserialize_associated_host")]
pub host: String,

#[serde(default)]
pub path: Vec<String>,
#[serde(default, alias = "path-pattern", rename = "pathPattern")]
pub path_pattern: Vec<String>,
#[serde(default, alias = "path-prefix", rename = "pathPrefix")]
pub path_prefix: Vec<String>,
#[serde(default, alias = "path-suffix", rename = "pathSuffix")]
pub path_suffix: Vec<String>,
}

// TODO: Consider removing this in v3
fn default_schemes() -> Vec<String> {
vec!["https".to_string(), "http".to_string()]
}

fn deserialize_associated_host<'de, D>(deserializer: D) -> Result<String, D::Error>
Expand Down
Loading