mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-24 17:20:51 +02:00
Merge commit from fork
* fix(shell): properly validate open scope * change empty regex to an impossible match --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app> Co-authored-by: Chip Reed <chip@chip.sh>
This commit is contained in:
@@ -119,6 +119,20 @@ impl Program {
|
||||
/// });
|
||||
/// ```
|
||||
#[deprecated(since = "2.1.0", note = "Use tauri-plugin-opener instead.")]
|
||||
pub fn open<P: AsRef<str>>(scope: &OpenScope, path: P, with: Option<Program>) -> crate::Result<()> {
|
||||
scope.open(path.as_ref(), with).map_err(Into::into)
|
||||
pub fn open<P: AsRef<str>>(
|
||||
scope: Option<&OpenScope>,
|
||||
path: P,
|
||||
with: Option<Program>,
|
||||
) -> crate::Result<()> {
|
||||
// validate scope if we have any (JS calls)
|
||||
if let Some(scope) = scope {
|
||||
scope.open(path.as_ref(), with).map_err(Into::into)
|
||||
} else {
|
||||
// when running directly from Rust code we don't need to validate the path
|
||||
match with.map(Program::name) {
|
||||
Some(program) => ::open::with_detached(path.as_ref(), program),
|
||||
None => ::open::that_detached(path.as_ref()),
|
||||
}
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user