fix blank case on NormalizeURL().
This commit is contained in:
@@ -6,6 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NormalizeURL(u string) string {
|
func NormalizeURL(u string) string {
|
||||||
|
if u == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
|
if !strings.HasPrefix(u, "http") && !strings.HasPrefix(u, "ws") {
|
||||||
u = "wss://" + u
|
u = "wss://" + u
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nostr
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func ExampleNormalizeURL() {
|
func ExampleNormalizeURL() {
|
||||||
|
fmt.Println(NormalizeURL(""))
|
||||||
fmt.Println(NormalizeURL("wss://x.com/y"))
|
fmt.Println(NormalizeURL("wss://x.com/y"))
|
||||||
fmt.Println(NormalizeURL("wss://x.com/y/"))
|
fmt.Println(NormalizeURL("wss://x.com/y/"))
|
||||||
fmt.Println(NormalizeURL("http://x.com/y"))
|
fmt.Println(NormalizeURL("http://x.com/y"))
|
||||||
@@ -16,6 +17,7 @@ func ExampleNormalizeURL() {
|
|||||||
fmt.Println(NormalizeURL("x.com/?x=23"))
|
fmt.Println(NormalizeURL("x.com/?x=23"))
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
|
//
|
||||||
// wss://x.com/y
|
// wss://x.com/y
|
||||||
// wss://x.com/y
|
// wss://x.com/y
|
||||||
// ws://x.com/y
|
// ws://x.com/y
|
||||||
|
|||||||
Reference in New Issue
Block a user