validating/parsing nip05 and nip46.

This commit is contained in:
fiatjaf
2024-03-01 15:54:28 -03:00
parent c5f6692f74
commit f4cf242084
4 changed files with 82 additions and 12 deletions

View File

@@ -3,11 +3,14 @@ package nip46
import (
"encoding/json"
"fmt"
"regexp"
"github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/nip04"
)
var BUNKER_REGEX = regexp.MustCompile(`^bunker:\/\/([0-9a-f]{64})\??([?\/\w:.=&%]*)$`)
type Request struct {
ID string `json:"id"`
Method string `json:"method"`
@@ -77,3 +80,7 @@ func (s Session) MakeResponse(
return resp, evt, nil
}
func IsValidBunkerURL(input string) bool {
return BUNKER_REGEX.MatchString(input)
}