diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-05-23 07:53:32 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-05-23 07:53:32 +0100 |
| commit | 2596140ba29dc959643ae02fb2db4de980ee12e9 (patch) | |
| tree | 54fcc06591020d7ff3d583311170f403a812916d /src/bin/ngit/sub_commands | |
| parent | f382b1307ea1020b7dc8fcd9c7fc02f2f612bef7 (diff) | |
fix: remove blossom url trailing slash
when creating announcment with `ngit init`
Diffstat (limited to 'src/bin/ngit/sub_commands')
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 70a2cd9..5c090ae 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -10,6 +10,7 @@ use anyhow::{Context, Result, bail}; | |||
| 10 | use console::Style; | 10 | use console::Style; |
| 11 | use dialoguer::theme::{ColorfulTheme, Theme}; | 11 | use dialoguer::theme::{ColorfulTheme, Theme}; |
| 12 | use ngit::{ | 12 | use ngit::{ |
| 13 | UrlWithoutSlash, | ||
| 13 | cli_interactor::{PromptChoiceParms, PromptConfirmParms, PromptMultiChoiceParms}, | 14 | cli_interactor::{PromptChoiceParms, PromptConfirmParms, PromptMultiChoiceParms}, |
| 14 | client::{Params, send_events}, | 15 | client::{Params, send_events}, |
| 15 | git::nostr_url::{CloneUrl, NostrUrlDecoded}, | 16 | git::nostr_url::{CloneUrl, NostrUrlDecoded}, |
| @@ -231,7 +232,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 231 | repo_ref | 232 | repo_ref |
| 232 | .blossoms | 233 | .blossoms |
| 233 | .iter() | 234 | .iter() |
| 234 | .map(std::string::ToString::to_string) | 235 | .map(UrlWithoutSlash::to_string_without_trailing_slash) |
| 235 | .collect::<Vec<String>>() | 236 | .collect::<Vec<String>>() |
| 236 | // } else if user_ref.blossoms.read().is_empty() { | 237 | // } else if user_ref.blossoms.read().is_empty() { |
| 237 | // client.get_fallback_relays().clone() | 238 | // client.get_fallback_relays().clone() |
| @@ -290,7 +291,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 290 | } | 291 | } |
| 291 | } | 292 | } |
| 292 | if args.blossoms.is_empty() { | 293 | if args.blossoms.is_empty() { |
| 293 | let blossom = format_ngit_blossom_url_as_relay_url(ngit_relay)?; | 294 | let blossom = format_ngit_relay_url_as_blossom_url(ngit_relay)?; |
| 294 | if !blossoms_defaults.contains(&blossom) { | 295 | if !blossoms_defaults.contains(&blossom) { |
| 295 | blossoms_defaults.push(blossom); | 296 | blossoms_defaults.push(blossom); |
| 296 | } | 297 | } |
| @@ -483,8 +484,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 483 | blossoms_defaults, | 484 | blossoms_defaults, |
| 484 | selections, | 485 | selections, |
| 485 | |s| { | 486 | |s| { |
| 486 | Url::parse(s) | 487 | format_ngit_relay_url_as_blossom_url(s) |
| 487 | .map(|_| s.to_string()) | ||
| 488 | .context(format!("Invalid blossom URL format: {s}")) | 488 | .context(format!("Invalid blossom URL format: {s}")) |
| 489 | }, | 489 | }, |
| 490 | )?; | 490 | )?; |
| @@ -974,10 +974,10 @@ fn format_ngit_relay_url_as_relay_url(url: &str) -> Result<String> { | |||
| 974 | Ok(format!("wss://{ngit_relay_url}")) | 974 | Ok(format!("wss://{ngit_relay_url}")) |
| 975 | } | 975 | } |
| 976 | 976 | ||
| 977 | fn format_ngit_blossom_url_as_relay_url(url: &str) -> Result<String> { | 977 | fn format_ngit_relay_url_as_blossom_url(url: &str) -> Result<String> { |
| 978 | let ngit_relay_url = normalize_ngit_relay_url(url)?; | 978 | let ngit_relay_url = normalize_ngit_relay_url(url)?; |
| 979 | if ngit_relay_url.contains("http://") { | 979 | if ngit_relay_url.contains("http://") { |
| 980 | return Ok(ngit_relay_url.to_string()); | 980 | return Ok(ngit_relay_url); |
| 981 | } | 981 | } |
| 982 | Ok(format!("https://{ngit_relay_url}")) | 982 | Ok(format!("https://{ngit_relay_url}")) |
| 983 | } | 983 | } |