trim nostr: prefix so it works again on fetch and flags.

This commit is contained in:
fiatjaf
2026-09-15 10:59:33 -03:00
parent 32dad77c33
commit 00b9e1f237
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -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")
+2
View File
@@ -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}
+3
View File
@@ -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