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