mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-29 02:01:02 +02:00
Support url without protocol in nip11.Fetch
This commit is contained in:
@ -18,10 +18,13 @@ func Fetch(ctx context.Context, u string) (info *RelayInformationDocument, err e
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize URL to start with http:// or https://
|
// normalize URL to start with http://, https:// or without protocol
|
||||||
if strings.HasPrefix(u, "ws") {
|
if strings.HasPrefix(u, "wss://") || strings.HasPrefix(u, "ws://") {
|
||||||
u = "http" + u[2:]
|
u = "http" + u[2:]
|
||||||
}
|
}
|
||||||
|
if !(strings.HasPrefix(u, "http://") || strings.HasPrefix(u, "https://")) {
|
||||||
|
u = "http://" + u
|
||||||
|
}
|
||||||
u = strings.TrimRight(u, "/")
|
u = strings.TrimRight(u, "/")
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
|
||||||
|
Reference in New Issue
Block a user