Event JSON
{
"id": "da4c7908b96e71ecfd0aa09cd1502deebeb4d4d88f9e6e330b8bd7909c3dfcbd",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1733176360,
"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"
],
[
"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/2] 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": "7ad07e77f458d73858d247589fbd96ded34e4d9297ce9f5996fc51b1eebbd4c51262c9336320db21e0a36d62dc1df65b1a3ed5a7521551e43c2f1d4da5567b5e"
}