Skip to content

Commit

Permalink
fix(deep-link): prevent duplicate ; in .desktop files on Linux (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars authored May 21, 2024
1 parent 43224c5 commit db45dfa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-deep-link-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
deep-link: patch
---

Fixed an issue that caused the `deep-link` plugin to generate incorrect `.desktop` files on Linux.
12 changes: 6 additions & 6 deletions plugins/deep-link/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit db45dfa

Please sign in to comment.