From 0f3969325385f2707e359cb28d9c49c509310452 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 28 Apr 2025 08:00:09 +0100 Subject: fix(init): replace legacy gitworkshop url with new format. but both default option and when previous web string used legacy format --- src/bin/ngit/sub_commands/init.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/bin') diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 3731e3a..9c544d6 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -356,15 +356,47 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { }; let web: Vec = if args.web.is_empty() { + let gitworkshop_url = NostrUrlDecoded { + original_string: String::new(), + coordinate: Nip19Coordinate { + coordinate: Coordinate { + public_key: user_ref.public_key, + kind: Kind::GitRepoAnnouncement, + identifier: identifier.clone(), + }, + relays: if let Some(relay) = relays.first() { + vec![relay.clone()] + } else { + vec![] + }, + }, + protocol: None, + user: None, + nip05: None, + } + .to_string() + .replace("nostr://", "https://gitworkshop.dev/"); Interactor::default() .input( PromptInputParms::default() .with_prompt("repo website") .optional() .with_default(if let Some(repo_ref) = &repo_ref { - repo_ref.web.clone().join(" ") + if repo_ref + .web + .clone() + .join(" ") + // replace legacy gitworkshop.dev url format with new one + .contains( + format!("https://gitworkshop.dev/repo/{}", &identifier).as_str(), + ) + { + gitworkshop_url + } else { + repo_ref.web.clone().join(" ") + } } else { - format!("https://gitworkshop.dev/repo/{}", &identifier) + gitworkshop_url }), )? .split(' ') -- cgit v1.2.3