Event JSON
{
"id": "29b2f4810dae7bf293e4da03c66204e090c2286441ddbf80ed5f76488d66b554",
"pubkey": "cfd7df62799a22e384a4ab5da8c4026c875b119d0f47c2716b20cdac9cc1f1a6",
"created_at": 1733311379,
"kind": 1617,
"tags": [
[
"a",
"30617:a008def15796fba9a0d6fab04e8fd57089285d9fd505da5a83fe8aad57a3564d:ngit"
],
[
"r",
"26689f97810fc656c7134c76e2a37d33b2e40ce7"
],
[
"r",
"3fc1a99b85fb20f78b1ea28e5daa75eef4688da5"
],
[
"alt",
"git patch: Parse NIP-05 address from a git remote URL"
],
[
"t",
"root"
],
[
"branch-name",
"nip05-lez"
],
[
"p",
"a008def15796fba9a0d6fab04e8fd57089285d9fd505da5a83fe8aad57a3564d"
],
[
"commit",
"3fc1a99b85fb20f78b1ea28e5daa75eef4688da5"
],
[
"parent-commit",
"a6a1eebda0ab5e8b34e97799ff7b57ef194261c7"
],
[
"commit-pgp-sig",
""
],
[
"description",
"Parse NIP-05 address from a git remote URL\n\nThe nip05 address is stored as it is, because we can't run async code in\nfrom_str().\nWe need to add an async resolve_nip05() to NostrUrlDecoded.\n"
],
[
"author",
"Laszlo Megyer",
"lez@github.com",
"1733142013",
"60"
],
[
"committer",
"Laszlo Megyer",
"lez@github.com",
"1733142013",
"60"
]
],
"content": "From 3fc1a99b85fb20f78b1ea28e5daa75eef4688da5 Mon Sep 17 00:00:00 2001\nFrom: Laszlo Megyer \u003clez@github.com\u003e\nDate: Mon, 2 Dec 2024 13:20:13 +0100\nSubject: [PATCH 1/3] Parse NIP-05 address from a git remote URL\n\nThe nip05 address is stored as it is, because we can't run async code in\nfrom_str().\nWe need to add an async resolve_nip05() to NostrUrlDecoded.\n---\n src/lib/git/nostr_url.rs | 27 +++++++++++++++++++--------\n src/lib/repo_ref.rs | 1 +\n 2 files changed, 20 insertions(+), 8 deletions(-)\n\ndiff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs\nindex a501765..be4a825 100644\n--- a/src/lib/git/nostr_url.rs\n+++ b/src/lib/git/nostr_url.rs\n@@ -59,6 +59,7 @@ pub struct NostrUrlDecoded {\n pub coordinates: HashSet\u003cCoordinate\u003e,\n pub protocol: Option\u003cServerProtocol\u003e,\n pub user: Option\u003cString\u003e,\n+ pub nip05: Option\u003cString\u003e,\n }\n \n impl fmt::Display for NostrUrlDecoded {\n@@ -98,6 +99,7 @@ impl std::str::FromStr for NostrUrlDecoded {\n let mut protocol = None;\n let mut user = None;\n let mut relays = vec![];\n+ let mut nip05 = None;\n \n if !url.starts_with(\"nostr://\") {\n bail!(\"nostr git url must start with nostr://\");\n@@ -134,16 +136,24 @@ impl std::str::FromStr for NostrUrlDecoded {\n .split('/')\n .collect();\n \n+ // split first part into user if present and hostname\n+ let part = parts.first().context(INCORRECT_NOSTR_URL_FORMAT_ERROR)?;\n+ let hostname = if let Some(at_index) = part.find('@') {\n+ // TODO throw error if user already set\n+ user = Some(part[..at_index].to_string());\n+ \u0026part[at_index + 1..]\n+ } else {\n+ part\n+ };\n+\n+ // check if it uses a NIP-05 address\n+ if hostname.contains('.') {\n+ nip05 = Some(part.to_string())\n+ }\n+\n // extract optional protocol\n if protocol.is_none() {\n- let part = parts.first().context(INCORRECT_NOSTR_URL_FORMAT_ERROR)?;\n- let protocol_str = if let Some(at_index) = part.find('@') {\n- user = Some(part[..at_index].to_string());\n- \u0026part[at_index + 1..]\n- } else {\n- part\n- };\n- protocol = match protocol_str {\n+ protocol = match hostname {\n \"ssh\" =\u003e Some(ServerProtocol::Ssh),\n \"https\" =\u003e Some(ServerProtocol::Https),\n \"http\" =\u003e Some(ServerProtocol::Http),\n@@ -196,6 +206,7 @@ impl std::str::FromStr for NostrUrlDecoded {\n coordinates,\n protocol,\n user,\n+ nip05,\n })\n }\n }\ndiff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs\nindex 69fbe64..877d1ee 100644\n--- a/src/lib/repo_ref.rs\n+++ b/src/lib/repo_ref.rs\n@@ -229,6 +229,7 @@ impl RepoRef {\n coordinates: HashSet::from_iter(vec![self.coordinate_with_hint()]),\n protocol: None,\n user: None,\n+ nip05: None,\n }\n )\n }\n--\nlibgit2 1.8.1\n\n",
"sig": "667770080b27420278cb3aeefa092d6b62018800dd929f0e24b957ec2158b15606dd1981da63220a73f10b7cbeaa078f25d88b1ab39ab80570c8d1c38b432394"
}