Skip to content

Commit 4d10ace

Browse files
feat(deep-link): Add more AssociatedDomain attributes (android) (#993)
Co-authored-by: FabianLars <[email protected]>
1 parent 2448e71 commit 4d10ace

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deep-link: minor
3+
deep-link-js: minor
4+
---
5+
6+
Exposed Android's `path`, `pathPattern` and `pathSuffix` configurations.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deep-link: minor
3+
deep-link-js: minor
4+
---
5+
6+
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.

plugins/deep-link/build.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,50 @@ use config::{AssociatedDomain, Config};
99
const COMMANDS: &[&str] = &["get_current", "register", "unregister", "is_registered"];
1010

1111
// TODO: Consider using activity-alias in case users may have multiple activities in their app.
12-
// TODO: Do we want to support the other path* configs too?
1312
fn intent_filter(domain: &AssociatedDomain) -> String {
1413
format!(
1514
r#"<intent-filter android:autoVerify="true">
1615
<action android:name="android.intent.action.VIEW" />
1716
<category android:name="android.intent.category.DEFAULT" />
1817
<category android:name="android.intent.category.BROWSABLE" />
19-
<data android:scheme="http" />
20-
<data android:scheme="https" />
18+
{}
2119
<data android:host="{}" />
2220
{}
21+
{}
22+
{}
23+
{}
2324
</intent-filter>"#,
25+
domain
26+
.scheme
27+
.iter()
28+
.map(|scheme| format!(r#"<data android:scheme="{scheme}" />"#))
29+
.collect::<Vec<_>>()
30+
.join("\n "),
2431
domain.host,
32+
domain
33+
.path
34+
.iter()
35+
.map(|path| format!(r#"<data android:path="{path}" />"#))
36+
.collect::<Vec<_>>()
37+
.join("\n "),
38+
domain
39+
.path_pattern
40+
.iter()
41+
.map(|pattern| format!(r#"<data android:pathPattern="{pattern}" />"#))
42+
.collect::<Vec<_>>()
43+
.join("\n "),
2544
domain
2645
.path_prefix
2746
.iter()
2847
.map(|prefix| format!(r#"<data android:pathPrefix="{prefix}" />"#))
2948
.collect::<Vec<_>>()
30-
.join("\n ")
49+
.join("\n "),
50+
domain
51+
.path_suffix
52+
.iter()
53+
.map(|suffix| format!(r#"<data android:pathSuffix="{suffix}" />"#))
54+
.collect::<Vec<_>>()
55+
.join("\n "),
3156
)
3257
}
3358

plugins/deep-link/src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,25 @@ use tauri_utils::config::DeepLinkProtocol;
99

1010
#[derive(Deserialize, Clone)]
1111
pub struct AssociatedDomain {
12+
#[serde(default = "default_schemes")]
13+
pub scheme: Vec<String>,
14+
1215
#[serde(deserialize_with = "deserialize_associated_host")]
1316
pub host: String,
17+
18+
#[serde(default)]
19+
pub path: Vec<String>,
20+
#[serde(default, alias = "path-pattern", rename = "pathPattern")]
21+
pub path_pattern: Vec<String>,
1422
#[serde(default, alias = "path-prefix", rename = "pathPrefix")]
1523
pub path_prefix: Vec<String>,
24+
#[serde(default, alias = "path-suffix", rename = "pathSuffix")]
25+
pub path_suffix: Vec<String>,
26+
}
27+
28+
// TODO: Consider removing this in v3
29+
fn default_schemes() -> Vec<String> {
30+
vec!["https".to_string(), "http".to_string()]
1631
}
1732

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

0 commit comments

Comments
 (0)