mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-08-17 19:07:12 +02:00
feat: Add deep link plugin for mobile (#504)
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
co-authored by
Lucas Nogueira
Lucas Nogueira
parent
2409b01fe7
commit
eccd6f977a
@@ -0,0 +1,36 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// This module is also imported in build.rs!
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct AssociatedDomain {
|
||||
#[serde(deserialize_with = "deserialize_associated_host")]
|
||||
pub host: String,
|
||||
#[serde(default, alias = "path-prefix", rename = "pathPrefix")]
|
||||
pub path_prefix: Vec<String>,
|
||||
}
|
||||
|
||||
fn deserialize_associated_host<'de, D>(deserializer: D) -> Result<String, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let host = String::deserialize(deserializer)?;
|
||||
if let Some((scheme, _host)) = host.split_once("://") {
|
||||
Err(serde::de::Error::custom(format!(
|
||||
"host `{host}` cannot start with a scheme, please remove the `{scheme}://` prefix"
|
||||
)))
|
||||
} else {
|
||||
Ok(host)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Config {
|
||||
pub domains: Vec<AssociatedDomain>,
|
||||
}
|
||||
Reference in New Issue
Block a user