nip34: grasp url helper.

This commit is contained in:
fiatjaf
2026-03-26 17:36:01 -03:00
parent b5974cfa45
commit 3acfbbca0a
+25
View File
@@ -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
}