add bootstrap flow

This commit is contained in:
2026-08-04 18:53:18 +07:00
parent ebdb07f652
commit 7300c5d1fd
5 changed files with 321 additions and 15 deletions
+9 -10
View File
@@ -11,7 +11,7 @@ pub enum CloneTarget {
UserRepo {
/// `npub1...` or a NIP-05 identifier.
user: String,
relay_hint: Option<String>,
relay_hint: Option<RelayUrl>,
/// `d` tag identifier of the repository.
identifier: String,
},
@@ -35,7 +35,10 @@ pub fn parse_clone_url(url: &str) -> Option<CloneTarget> {
}
let (relay_hint, identifier) = match third {
Some(id) => (Some(percent_decode(second)), percent_decode(id)),
Some(id) => (
RelayUrl::parse(&percent_decode(second)).ok(),
percent_decode(id),
),
None => (None, percent_decode(second)),
};
@@ -78,8 +81,7 @@ mod tests {
assert_eq!(
target,
CloneTarget::UserRepo {
user: "npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr"
.to_owned(),
user: "npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr".to_owned(),
relay_hint: None,
identifier: "ngit".to_owned(),
}
@@ -88,15 +90,12 @@ mod tests {
#[test]
fn parses_user_repo_with_relay_hint() {
let target = parse_clone_url(
"nostr://danconwaydev.com/relay.ngit.dev/ngit",
)
.unwrap();
let target = parse_clone_url("nostr://danconwaydev.com/relay.ngit.dev/ngit").unwrap();
assert_eq!(
target,
CloneTarget::UserRepo {
user: "danconwaydev.com".to_owned(),
relay_hint: Some("relay.ngit.dev".to_owned()),
relay_hint: RelayUrl::parse("relay.ngit.dev").ok(),
identifier: "ngit".to_owned(),
}
);
@@ -112,7 +111,7 @@ mod tests {
target,
CloneTarget::UserRepo {
user: "danconwaydev.com".to_owned(),
relay_hint: Some("ws://localhost:7334".to_owned()),
relay_hint: RelayUrl::parse("ws://localhost:7334").ok(),
identifier: "my-local-only-repo".to_owned(),
}
);