diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:08:25 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:08:25 +0000 |
| commit | 83448a99aaf18c7a045a081c5de0c22bc4a83de1 (patch) | |
| tree | 28076a33b40e63937d79a8fe8d54b58d42db092c /src/lib/git | |
| parent | 5478aa74cc26452809e499a461067ca9744cb7ce (diff) | |
chore: bump rust-nosrt v0.37.0
use RelayUrl in repo_ref which I had resisted as it mutates relay
urls when printed to append a slash
Diffstat (limited to 'src/lib/git')
| -rw-r--r-- | src/lib/git/nostr_url.rs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs index b310782..e4b6825 100644 --- a/src/lib/git/nostr_url.rs +++ b/src/lib/git/nostr_url.rs | |||
| @@ -3,7 +3,7 @@ use std::{collections::HashSet, str::FromStr}; | |||
| 3 | 3 | ||
| 4 | use anyhow::{anyhow, bail, Context, Error, Result}; | 4 | use anyhow::{anyhow, bail, Context, Error, Result}; |
| 5 | use nostr::nips::nip01::Coordinate; | 5 | use nostr::nips::nip01::Coordinate; |
| 6 | use nostr_sdk::{PublicKey, Url}; | 6 | use nostr_sdk::{PublicKey, RelayUrl, Url}; |
| 7 | 7 | ||
| 8 | #[derive(Debug, PartialEq, Default, Clone)] | 8 | #[derive(Debug, PartialEq, Default, Clone)] |
| 9 | pub enum ServerProtocol { | 9 | pub enum ServerProtocol { |
| @@ -85,8 +85,8 @@ impl std::str::FromStr for NostrUrlDecoded { | |||
| 85 | decoded = format!("wss://{decoded}"); | 85 | decoded = format!("wss://{decoded}"); |
| 86 | } | 86 | } |
| 87 | let url = | 87 | let url = |
| 88 | Url::parse(&decoded).context("could not parse relays in nostr git url")?; | 88 | RelayUrl::parse(&decoded).context("could not parse relays in nostr git url")?; |
| 89 | relays.push(url.to_string()); | 89 | relays.push(url); |
| 90 | } else if name == "protocol" { | 90 | } else if name == "protocol" { |
| 91 | protocol = match value.as_ref() { | 91 | protocol = match value.as_ref() { |
| 92 | "ssh" => Some(ServerProtocol::Ssh), | 92 | "ssh" => Some(ServerProtocol::Ssh), |
| @@ -151,8 +151,8 @@ impl std::str::FromStr for NostrUrlDecoded { | |||
| 151 | decoded = format!("wss://{decoded}"); | 151 | decoded = format!("wss://{decoded}"); |
| 152 | } | 152 | } |
| 153 | let url = | 153 | let url = |
| 154 | Url::parse(&decoded).context("could not parse relays in nostr git url")?; | 154 | RelayUrl::parse(&decoded).context("could not parse relays in nostr git url")?; |
| 155 | relays.push(url.to_string()); | 155 | relays.push(url); |
| 156 | } | 156 | } |
| 157 | coordinates.insert(Coordinate { | 157 | coordinates.insert(Coordinate { |
| 158 | identifier, | 158 | identifier, |
| @@ -852,7 +852,7 @@ mod tests { | |||
| 852 | .unwrap(), | 852 | .unwrap(), |
| 853 | kind: nostr_sdk::Kind::GitRepoAnnouncement, | 853 | kind: nostr_sdk::Kind::GitRepoAnnouncement, |
| 854 | relays: if relays { | 854 | relays: if relays { |
| 855 | vec!["wss://nos.lol/".to_string()] | 855 | vec![RelayUrl::parse("wss://nos.lol").unwrap()] |
| 856 | } else { | 856 | } else { |
| 857 | vec![] | 857 | vec![] |
| 858 | }, | 858 | }, |
| @@ -873,7 +873,8 @@ mod tests { | |||
| 873 | ) | 873 | ) |
| 874 | .unwrap(), | 874 | .unwrap(), |
| 875 | kind: nostr_sdk::Kind::GitRepoAnnouncement, | 875 | kind: nostr_sdk::Kind::GitRepoAnnouncement, |
| 876 | relays: vec!["wss://nos.lol".to_string()], // wont add the slash | 876 | relays: vec![RelayUrl::parse("wss://nos.lol").unwrap()], /* wont add the |
| 877 | * slash */ | ||
| 877 | }]), | 878 | }]), |
| 878 | protocol: None, | 879 | protocol: None, |
| 879 | user: None, | 880 | user: None, |
| @@ -942,8 +943,8 @@ mod tests { | |||
| 942 | fn with_multiple_encoded_relays() -> Result<()> { | 943 | fn with_multiple_encoded_relays() -> Result<()> { |
| 943 | let url = format!( | 944 | let url = format!( |
| 944 | "nostr://npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit?relay={}&relay1={}", | 945 | "nostr://npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit?relay={}&relay1={}", |
| 945 | urlencoding::encode("wss://nos.lol"), | 946 | urlencoding::encode("wss://nos.lol/"), |
| 946 | urlencoding::encode("wss://relay.damus.io"), | 947 | urlencoding::encode("wss://relay.damus.io/"), |
| 947 | ); | 948 | ); |
| 948 | assert_eq!( | 949 | assert_eq!( |
| 949 | NostrUrlDecoded::from_str(&url)?, | 950 | NostrUrlDecoded::from_str(&url)?, |
| @@ -957,8 +958,8 @@ mod tests { | |||
| 957 | .unwrap(), | 958 | .unwrap(), |
| 958 | kind: nostr_sdk::Kind::GitRepoAnnouncement, | 959 | kind: nostr_sdk::Kind::GitRepoAnnouncement, |
| 959 | relays: vec![ | 960 | relays: vec![ |
| 960 | "wss://nos.lol/".to_string(), | 961 | RelayUrl::parse("wss://nos.lol/").unwrap(), |
| 961 | "wss://relay.damus.io/".to_string(), | 962 | RelayUrl::parse("wss://relay.damus.io/").unwrap(), |
| 962 | ], | 963 | ], |
| 963 | }]), | 964 | }]), |
| 964 | protocol: None, | 965 | protocol: None, |
| @@ -1039,8 +1040,8 @@ mod tests { | |||
| 1039 | fn with_multiple_encoded_relays() -> Result<()> { | 1040 | fn with_multiple_encoded_relays() -> Result<()> { |
| 1040 | let url = format!( | 1041 | let url = format!( |
| 1041 | "nostr://npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/{}/{}/ngit", | 1042 | "nostr://npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/{}/{}/ngit", |
| 1042 | urlencoding::encode("wss://nos.lol"), | 1043 | urlencoding::encode("wss://nos.lol/"), |
| 1043 | urlencoding::encode("wss://relay.damus.io"), | 1044 | urlencoding::encode("wss://relay.damus.io/"), |
| 1044 | ); | 1045 | ); |
| 1045 | assert_eq!( | 1046 | assert_eq!( |
| 1046 | NostrUrlDecoded::from_str(&url)?, | 1047 | NostrUrlDecoded::from_str(&url)?, |
| @@ -1054,8 +1055,8 @@ mod tests { | |||
| 1054 | .unwrap(), | 1055 | .unwrap(), |
| 1055 | kind: nostr_sdk::Kind::GitRepoAnnouncement, | 1056 | kind: nostr_sdk::Kind::GitRepoAnnouncement, |
| 1056 | relays: vec![ | 1057 | relays: vec![ |
| 1057 | "wss://nos.lol/".to_string(), | 1058 | RelayUrl::parse("wss://nos.lol/").unwrap(), |
| 1058 | "wss://relay.damus.io/".to_string(), | 1059 | RelayUrl::parse("wss://relay.damus.io/").unwrap(), |
| 1059 | ], | 1060 | ], |
| 1060 | }]), | 1061 | }]), |
| 1061 | protocol: None, | 1062 | protocol: None, |