2023-02-27 16:30:48 -03:00
|
|
|
package nostr
|
|
|
|
|
|
|
|
import (
|
2024-01-18 16:27:56 -03:00
|
|
|
"encoding/hex"
|
2023-07-08 08:16:30 -03:00
|
|
|
"net/url"
|
2023-02-27 16:30:48 -03:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2023-07-08 08:16:30 -03:00
|
|
|
func IsValidRelayURL(u string) bool {
|
|
|
|
parsed, err := url.Parse(u)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if parsed.Scheme != "wss" && parsed.Scheme != "ws" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
2024-01-18 16:27:56 -03:00
|
|
|
|
|
|
|
func IsValid32ByteHex(thing string) bool {
|
|
|
|
if strings.ToLower(thing) != thing {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if len(thing) != 64 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
_, err := hex.DecodeString(thing)
|
|
|
|
return err == nil
|
|
|
|
}
|