From b57668e4db11e206a20b084fbf07ad7945574d56 Mon Sep 17 00:00:00 2001 From: FabianLars Date: Tue, 21 May 2024 18:27:15 +0200 Subject: [PATCH] fix(deep-link): prevent duplicate `;` in .desktop files on Linux --- .changes/fix-deep-link-linux.md | 5 +++++ plugins/deep-link/src/lib.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changes/fix-deep-link-linux.md diff --git a/.changes/fix-deep-link-linux.md b/.changes/fix-deep-link-linux.md new file mode 100644 index 000000000..594342675 --- /dev/null +++ b/.changes/fix-deep-link-linux.md @@ -0,0 +1,5 @@ +--- +deep-link: patch +--- + +Fixed an issue that caused the `deep-link` plugin to generate incorrect `.desktop` files on Linux. diff --git a/plugins/deep-link/src/lib.rs b/plugins/deep-link/src/lib.rs index 290b8f57f..38e950b8a 100644 --- a/plugins/deep-link/src/lib.rs +++ b/plugins/deep-link/src/lib.rs @@ -219,15 +219,15 @@ mod imp { let target_file = target.join(&file_name); - let mime_type = format!("x-scheme-handler/{};", _protocol.as_ref()); + let mime_type = format!("x-scheme-handler/{}", _protocol.as_ref()); if let Ok(mut desktop_file) = ini::Ini::load_from_file(&target_file) { if let Some(section) = desktop_file.section_mut(Some("Desktop Entry")) { - if let Some(mimes) = section.remove("MimeType") { - section.append("MimeType", format!("{mimes};{mime_type};")) - } else { - section.append("MimeType", format!("{mime_type};")) - } + let old_mimes = section.remove("MimeType"); + section.append( + "MimeType", + format!("{mime_type};{}", old_mimes.unwrap_or_default()), + ); desktop_file.write_to_file(&target_file)?; } } else {