diff --git a/.changes/fix-path-scope-first-component.md b/.changes/fix-path-scope-first-component.md new file mode 100644 index 000000000..bf0f8e5e3 --- /dev/null +++ b/.changes/fix-path-scope-first-component.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Fixes filesystem and asset scope stripping the first component of the allowed path. diff --git a/core/tauri/src/api/path.rs b/core/tauri/src/api/path.rs index 7be3f594a..464e36072 100644 --- a/core/tauri/src/api/path.rs +++ b/core/tauri/src/api/path.rs @@ -138,18 +138,22 @@ pub fn parse>( ) -> crate::api::Result { let mut p = PathBuf::new(); let mut components = path.as_ref().components(); - if let Some(Component::Normal(str)) = components.next() { - if let Some(base_directory) = BaseDirectory::from_variable(&str.to_string_lossy()) { - p.push(resolve_path( - config, - package_info, - env, - "", - Some(base_directory), - )?); - } else { - p.push(str); + match components.next() { + Some(Component::Normal(str)) => { + if let Some(base_directory) = BaseDirectory::from_variable(&str.to_string_lossy()) { + p.push(resolve_path( + config, + package_info, + env, + "", + Some(base_directory), + )?); + } else { + p.push(str); + } } + Some(component) => p.push(component), + None => (), } for component in components {