mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-22 06:41:06 +02:00
fix blank case on NormalizeURL().
This commit is contained in:
parent
89cb5ad461
commit
b2885d57cd
@ -6,6 +6,10 @@ import (
|
||||
)
|
||||
|
||||
func NormalizeURL(u string) string {
|
||||
if u == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
|
||||
u = "wss://" + u
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package nostr
|
||||
import "fmt"
|
||||
|
||||
func ExampleNormalizeURL() {
|
||||
fmt.Println(NormalizeURL(""))
|
||||
fmt.Println(NormalizeURL("wss://x.com/y"))
|
||||
fmt.Println(NormalizeURL("wss://x.com/y/"))
|
||||
fmt.Println(NormalizeURL("http://x.com/y"))
|
||||
@ -16,6 +17,7 @@ func ExampleNormalizeURL() {
|
||||
fmt.Println(NormalizeURL("x.com/?x=23"))
|
||||
|
||||
// Output:
|
||||
//
|
||||
// wss://x.com/y
|
||||
// wss://x.com/y
|
||||
// ws://x.com/y
|
||||
|
Loading…
x
Reference in New Issue
Block a user