nostr package, readme updates accordingly, matching example program (#14)

This commit is contained in:
BitcoinCoderBob
2022-10-12 16:24:30 -04:00
committed by GitHub
parent e47c80a63d
commit 9549c3624a
14 changed files with 102 additions and 9 deletions

View File

@@ -1,28 +0,0 @@
package nostr
import (
"net/url"
"strings"
)
func NormalizeURL(u string) string {
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
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]
}
return p.String()
}