diff --git a/nip11/fetch.go b/nip11/fetch.go index 1bfc1e7..3c201f1 100644 --- a/nip11/fetch.go +++ b/nip11/fetch.go @@ -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)