fix localhost trick from 8aaf5b.

This commit is contained in:
fiatjaf
2024-07-04 16:29:04 -03:00
parent f9fd760808
commit 92b85c9483
2 changed files with 4 additions and 5 deletions

View File

@@ -15,13 +15,12 @@ func NormalizeURL(u string) string {
u = strings.TrimSpace(u)
u = strings.ToLower(u)
if strings.HasPrefix(u, "localhost") == true {
if strings.Split(u, ":")[0] == "localhost" {
u = "ws://" + u
}
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
} else if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
u = "wss://" + u
}
p, err := url.Parse(u)
if err != nil {
return ""