From 47622eb762e802a9caa2f37d8162eaaf2f9aa9ca Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 10 Apr 2026 16:25:26 +0000 Subject: fix: percent-encode identifier in nostr:// URLs and GRASP HTTP paths Repository identifiers can contain any characters per NIP-01 d-tag rules. Encode them in nostr:// clone URLs (display and parse) and in GRASP //.git paths, aligning with NIP-34 and GRASP-01. --- src/lib/repo_ref.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/lib/repo_ref.rs') diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs index c0f9136..c4dd820 100644 --- a/src/lib/repo_ref.rs +++ b/src/lib/repo_ref.rs @@ -14,6 +14,7 @@ use nostr::{ }; use nostr_sdk::{Kind, NostrSigner, RelayUrl, Timestamp, Url}; use serde::{Deserialize, Serialize}; +use urlencoding::encode as pct_encode; #[cfg(not(test))] use crate::client::Client; @@ -661,7 +662,7 @@ pub fn detect_existing_grasp_servers( } let clone_url_is_grasp_server_format = if let Ok(npub) = extract_npub(url) { - url.contains(&format!("/{npub}/{identifier}.git")) + url.contains(&format!("/{npub}/{}.git", pct_encode(identifier))) } else { false }; @@ -809,8 +810,9 @@ pub fn format_grasp_server_url_as_clone_url( "https://" }; Ok(format!( - "{prefix}{grasp_server_url}/{}/{identifier}.git", - public_key.to_bech32()? + "{prefix}{grasp_server_url}/{}/{}.git", + public_key.to_bech32()?, + pct_encode(identifier) )) } -- cgit v1.2.3