From c06c04067b380f7031259be44d0fcc3b8498bfc0 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Fri, 6 Sep 2024 09:55:58 +0200 Subject: [PATCH] Support files without an extension in XDG portal filters 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). --- src/backend/xdg_desktop_portal.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/xdg_desktop_portal.rs b/src/backend/xdg_desktop_portal.rs index 4d6b358..51bb5de 100644 --- a/src/backend/xdg_desktop_portal.rs +++ b/src/backend/xdg_desktop_portal.rs @@ -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 }