From: Thomas Christensen Date: Sun, 17 May 2026 04:54:42 +0700 Subject: app: normalize magnet URIs before adding MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit gio::File::for_uri("magnet:?xt=…").uri() re-emits the URI in hierarchical form ("magnet:///?xt=…"). Transmission's torrent-add RPC rejects this form, so opening a magnet link from a browser via the D-Bus Open() path failed with the generic "Unable to add torrent" toast. Strip the spurious empty authority before handing the URI to add_torrent_by_link so transmission receives the canonical magnet:?xt=… form. Clipboard-detection and the add-link GAction were already unaffected because they bypass gio::File. Forwarded: https://gitlab.gnome.org/World/Fragments/-/merge_requests/202 --- src/app.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index f599bb4..0b95c22 100644 --- a/src/app.rs +++ b/src/app.rs @@ -563,12 +563,25 @@ impl FrgApplication { } else { // URI, means magnet or torrent link let uri = file.uri().to_string(); - self.imp().add_torrent_by_link(uri); + self.imp().add_torrent_by_link(normalize_magnet_uri(uri)); } } } } +// `gio::File::for_uri("magnet:?xt=…").uri()` re-emits magnet URIs in +// hierarchical form (`magnet:///?xt=…`), which transmission's torrent-add +// rejects. Strip the spurious empty authority so we hand transmission the +// canonical `magnet:?xt=…` form. +fn normalize_magnet_uri(uri: String) -> String { + if let Some(rest) = uri.strip_prefix("magnet:") { + let rest = rest.trim_start_matches('/'); + format!("magnet:{rest}") + } else { + uri + } +} + impl Default for FrgApplication { fn default() -> Self { gio::Application::default()