diff --git a/nip34/grasp/helpers.go b/nip34/grasp/helpers.go new file mode 100644 index 0000000..f2b02f5 --- /dev/null +++ b/nip34/grasp/helpers.go @@ -0,0 +1,25 @@ +package grasp + +import ( + "net/url" + "strings" + + "fiatjaf.com/nostr/nip19" +) + +func IsGraspURL(u string) bool { + parsed, err := url.Parse(u) + if err != nil { + return false + } + + if strings.Count(parsed.Path, "/") != 2 || len(parsed.Path) < 65 { + return false + } + + if prefix, _, err := nip19.Decode(parsed.Path[1:64]); err != nil || prefix != "npub" { + return false + } + + return true +}