diff --git a/fetch.go b/fetch.go index e29c276..01946a9 100644 --- a/fetch.go +++ b/fetch.go @@ -43,6 +43,7 @@ var fetch = &cli.Command{ } for code := range getStdinLinesOrArguments(c.Args()) { + code = strings.TrimPrefix(code, "nostr:") var filter nostr.Filter var authorHint nostr.PubKey relays := c.StringSlice("relay") diff --git a/flags.go b/flags.go index fd7b504..0b36da3 100644 --- a/flags.go +++ b/flags.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "strconv" + "strings" "time" "fiatjaf.com/nostr" @@ -253,6 +254,7 @@ func (t pubKeyOrAddressValue) ToString(b PubKeyOrAddress) string { } func (t *pubKeyOrAddressValue) Set(value string) error { + value = strings.TrimPrefix(value, "nostr:") pubkey, err1 := parsePubKey(value) if err1 == nil { t.value = PubKeyOrAddress{PubKey: pubkey} diff --git a/helpers.go b/helpers.go index d6feed8..657d729 100644 --- a/helpers.go +++ b/helpers.go @@ -476,6 +476,7 @@ func askConfirmation(msg string) bool { } func parsePubKey(value string) (nostr.PubKey, error) { + value = strings.TrimPrefix(value, "nostr:") if nip05.IsValidIdentifier(value) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) pp, err := nip05.QueryIdentifier(ctx, value) @@ -508,6 +509,7 @@ func parsePubKey(value string) (nostr.PubKey, error) { } func parseSecretKey(input string) (nostr.SecretKey, error) { + input = strings.TrimPrefix(input, "nostr:") if prefix, ski, err := nip19.Decode(input); err == nil && prefix == "nsec" { return ski.(nostr.SecretKey), nil } @@ -521,6 +523,7 @@ func parseSecretKey(input string) (nostr.SecretKey, error) { } func parseEventID(value string) (nostr.ID, error) { + value = strings.TrimPrefix(value, "nostr:") id, err := nostr.IDFromHex(value) if err == nil { return id, nil