mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
d198c01486
Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use serde::Deserialize;
|
|
|
|
/// Configuration for the shell plugin.
|
|
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize)]
|
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
|
pub struct Config {
|
|
/// Open URL with the user's default application.
|
|
#[serde(default)]
|
|
pub open: ShellAllowlistOpen,
|
|
}
|
|
|
|
/// Defines the `shell > open` api scope.
|
|
#[derive(Debug, PartialEq, Eq, Clone, Deserialize)]
|
|
#[serde(untagged, deny_unknown_fields)]
|
|
#[non_exhaustive]
|
|
pub enum ShellAllowlistOpen {
|
|
/// If the shell open API should be enabled.
|
|
///
|
|
/// If enabled, the default validation regex (`^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`) is used.
|
|
Flag(bool),
|
|
|
|
/// Enable the shell open API, with a custom regex that the opened path must match against.
|
|
///
|
|
/// If using a custom regex to support a non-http(s) schema, care should be used to prevent values
|
|
/// that allow flag-like strings to pass validation. e.g. `--enable-debugging`, `-i`, `/R`.
|
|
Validate(String),
|
|
}
|
|
|
|
impl Default for ShellAllowlistOpen {
|
|
fn default() -> Self {
|
|
Self::Flag(false)
|
|
}
|
|
}
|