adapt relaypool to the new nip-01.
This commit is contained in:
+7
-11
@@ -7,26 +7,22 @@ import (
|
||||
|
||||
func NormalizeURL(u string) string {
|
||||
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
|
||||
u = "ws://" + u
|
||||
u = "wss://" + u
|
||||
}
|
||||
p, err := url.Parse(u)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
if p.Scheme == "http" {
|
||||
p.Scheme = "ws"
|
||||
} else if p.Scheme == "https" {
|
||||
p.Scheme = "wss"
|
||||
}
|
||||
|
||||
if strings.HasSuffix(p.RawPath, "/") {
|
||||
p.RawPath = p.RawPath[0 : len(p.RawPath)-1]
|
||||
}
|
||||
|
||||
if strings.HasSuffix(p.RawPath, "/ws") {
|
||||
p.RawPath = p.RawPath[0 : len(p.RawPath)-3]
|
||||
}
|
||||
|
||||
return p.String()
|
||||
}
|
||||
|
||||
func WebsocketURL(u string) string {
|
||||
p, _ := url.Parse(NormalizeURL(u))
|
||||
p.RawPath += "/ws"
|
||||
return p.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user