mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 08:19:06 -05:00
accept relay URLs without scheme everywhere.
This commit is contained in:
parent
eccce6dc4a
commit
363bd66a8a
|
@ -85,7 +85,7 @@ var encode = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
relays := c.StringSlice("relay")
|
relays := c.StringSlice("relay")
|
||||||
if err := validateRelayURLs(relays); err != nil {
|
if err := normalizeAndValidateRelayURLs(relays); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ var encode = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
relays := c.StringSlice("relay")
|
relays := c.StringSlice("relay")
|
||||||
if err := validateRelayURLs(relays); err != nil {
|
if err := normalizeAndValidateRelayURLs(relays); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ var encode = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
relays := c.StringSlice("relay")
|
relays := c.StringSlice("relay")
|
||||||
if err := validateRelayURLs(relays); err != nil {
|
if err := normalizeAndValidateRelayURLs(relays); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
fetch.go
4
fetch.go
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
var fetch = &cli.Command{
|
var fetch = &cli.Command{
|
||||||
Name: "fetch",
|
Name: "fetch",
|
||||||
Usage: "fetches events related to the given nip19 code from the included relay hints",
|
Usage: "fetches events related to the given nip19 code from the included relay hints or the author's NIP-65 relays.",
|
||||||
Description: `example usage:
|
Description: `example usage:
|
||||||
nak fetch nevent1qqsxrwm0hd3s3fddh4jc2574z3xzufq6qwuyz2rvv3n087zvym3dpaqprpmhxue69uhhqatzd35kxtnjv4kxz7tfdenju6t0xpnej4
|
nak fetch nevent1qqsxrwm0hd3s3fddh4jc2574z3xzufq6qwuyz2rvv3n087zvym3dpaqprpmhxue69uhhqatzd35kxtnjv4kxz7tfdenju6t0xpnej4
|
||||||
echo npub1h8spmtw9m2huyv6v2j2qd5zv956z2zdugl6mgx02f2upffwpm3nqv0j4ps | nak fetch --relay wss://relay.nostr.band`,
|
echo npub1h8spmtw9m2huyv6v2j2qd5zv956z2zdugl6mgx02f2upffwpm3nqv0j4ps | nak fetch --relay wss://relay.nostr.band`,
|
||||||
|
@ -41,7 +41,7 @@ var fetch = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
relays := c.StringSlice("relay")
|
relays := c.StringSlice("relay")
|
||||||
if err := validateRelayURLs(relays); err != nil {
|
if err := normalizeAndValidateRelayURLs(relays); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var authorHint string
|
var authorHint string
|
||||||
|
|
|
@ -92,8 +92,11 @@ func writeStdinLinesOrNothing(ch chan string) (hasStdinLines bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateRelayURLs(wsurls []string) error {
|
func normalizeAndValidateRelayURLs(wsurls []string) error {
|
||||||
for _, wsurl := range wsurls {
|
for i, wsurl := range wsurls {
|
||||||
|
wsurl = nostr.NormalizeURL(wsurl)
|
||||||
|
wsurls[i] = wsurl
|
||||||
|
|
||||||
u, err := url.Parse(wsurl)
|
u, err := url.Parse(wsurl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid relay url '%s': %s", wsurl, err)
|
return fmt.Errorf("invalid relay url '%s': %s", wsurl, err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user