Skip to content

Commit

Permalink
fix: prepend urls starting with www with https (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden authored Jun 30, 2024
1 parent 8cfd72f commit 553d3b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions rm-main/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ async fn add_torrent(config: &Config, torrent: String) -> Result<()> {
filename: Some(torrent),
..Default::default()
}
} else if torrent.starts_with("www") {
TorrentAddArgs {
filename: Some(format!("https://{torrent}")),
..Default::default()
}
} else {
let mut torrent_file = File::open(torrent)?;
let mut buf = vec![];
Expand Down
9 changes: 8 additions & 1 deletion rm-main/src/transmission/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ pub async fn action_handler(ctx: app::Ctx, mut trans_rx: UnboundedReceiver<Torre
while let Some(action) = trans_rx.recv().await {
match action {
TorrentAction::Add(ref url, directory) => {
let formatted = {
if url.starts_with("www") {
format!("https://{url}")
} else {
url.to_string()
}
};
let args = TorrentAddArgs {
filename: Some(url.clone()),
filename: Some(formatted),
download_dir: directory,
..Default::default()
};
Expand Down

0 comments on commit 553d3b7

Please sign in to comment.