5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-15 06:30:25 +00:00
matterbridge/vendor/github.com/nlopes/slack/websocket_utils.go
2016-09-05 16:34:37 +02:00

21 lines
426 B
Go

package slack
import (
"net"
"net/url"
)
var portMapping = map[string]string{"ws": "80", "wss": "443"}
func websocketizeURLPort(orig string) (string, error) {
urlObj, err := url.ParseRequestURI(orig)
if err != nil {
return "", err
}
_, _, err = net.SplitHostPort(urlObj.Host)
if err != nil {
return urlObj.Scheme + "://" + urlObj.Host + ":" + portMapping[urlObj.Scheme] + urlObj.Path, nil
}
return orig, nil
}