diff --git a/.changes/no-dest-resource-target.md b/.changes/no-dest-resource-target.md new file mode 100644 index 000000000000..926b8e8c8cf3 --- /dev/null +++ b/.changes/no-dest-resource-target.md @@ -0,0 +1,17 @@ +--- +"tauri-utils": "patch:bug" +--- + +Fix a regression in tauri-utils 2.8.3 that made empty path an invalid resource target, e.g. + +```json +{ + "bundle": { + "resources": { + "README.md": "", + } + } +} +``` + +(this means `README.md` -> `$RESOURCE/README.md`, note this is a confusing behavior, and will be changed in v3) diff --git a/crates/tauri-utils/src/resources.rs b/crates/tauri-utils/src/resources.rs index 3fd0290b78ac..d1ecd06ae081 100644 --- a/crates/tauri-utils/src/resources.rs +++ b/crates/tauri-utils/src/resources.rs @@ -209,7 +209,21 @@ impl ResourcePathsIter<'_> { // preserving the file name as it is ResourcePathsInnerIter::Glob { .. } => dest.join(path.file_name().unwrap()), }, - None => dest.clone(), + None => { + if dest.components().count() == 0 { + // if current_dest is empty while processing a file pattern + // we preserve the file name as it is + // + // e.g. `{ "README.md": "" }` is `README.md` -> `$RESOURCE/README.md` + // + // TODO: This behavior is a confusing special case, + // remove this in v3 or make other cases like this work + // > `{ "README.md": "./folder/" }` is `README.md` -> `$RESOURCE/folder/README.md` (this gives `$RESOURCE/folder` today) + PathBuf::from(path.file_name().unwrap()) + } else { + dest.clone() + } + } } } else { // If [`ResourcePathsIter::pattern_iter`] is a [`PatternIter::Slice`]