fix url parsing

This commit is contained in:
guochao 2024-01-26 23:15:33 +08:00
parent 87c44b29ea
commit 6a81d2f348

View File

@ -97,9 +97,18 @@ Type a message and press Enter to send.`)
if err != nil {
panic(err)
}
port := parsedUrl.Port()
if parsedUrl.Scheme == "https" {
transportCredential = credentials.NewTLS(&tls.Config{})
}
if port == "" {
switch parsedUrl.Scheme {
case "https":
port = "443"
default:
port = "80"
}
}
client := &SignalClient{
UI: SignalClientUI{
@ -115,7 +124,7 @@ Type a message and press Enter to send.`)
},
},
Server: fmt.Sprintf("%v:%v", parsedUrl.Hostname(), parsedUrl.Port()),
Server: fmt.Sprintf("%v:%v", parsedUrl.Hostname(), port),
Credential: transportCredential,
Room: room,