Skip to content

Commit

Permalink
Support files without an extension in XDG portal filters
Browse files Browse the repository at this point in the history
Due to the glob being used ("*.{file_extension}"), there was no
possibility to include files without a dot in their name when using filters.
The glob "*" is now used when an empty filter ("") or a match-all
filter ("*") is specified, which replaces globs "*." and "*.*" respectively.
The glob "*." did not make sense, as it matched files ending with a dot,
and "*.*" did not match files without an extension (which are quite popular on Linux).
  • Loading branch information
kjarosh committed Sep 6, 2024
1 parent 665230c commit c06c040
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/backend/xdg_desktop_portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ impl From<&Filter> for FileFilter {
fn from(filter: &Filter) -> Self {
let mut ashpd_filter = FileFilter::new(&filter.name);
for file_extension in &filter.extensions {
ashpd_filter = ashpd_filter.glob(&format!("*.{file_extension}"));
if file_extension == "*" || file_extension == "" {
ashpd_filter = ashpd_filter.glob("*");
} else {
ashpd_filter = ashpd_filter.glob(&format!("*.{file_extension}"));
}
}
ashpd_filter
}
Expand Down

0 comments on commit c06c040

Please sign in to comment.