Codebase list golang-github-nlopes-slack / 02a2274
update per PR feedback Demitrious Kelly 6 years ago
2 changed file(s) with 0 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
2626 if !response.Ok {
2727 return nil, "", response.Error
2828 }
29
30 // websocket.Dial does not accept url without the port (yet)
31 // Fixed by: https://github.com/golang/net/commit/5058c78c3627b31e484a81463acd51c7cecc06f3
32 // but slack returns the address with no port, so we have to fix it
3329 api.Debugln("Using URL:", response.Info.URL)
3430 return &response.Info, response.Info.URL, nil
3531 }
5349 if !response.Ok {
5450 return nil, "", response.Error
5551 }
56
57 // websocket.Dial does not accept url without the port (yet)
58 // Fixed by: https://github.com/golang/net/commit/5058c78c3627b31e484a81463acd51c7cecc06f3
59 // but slack returns the address with no port, so we have to fix it
6052 api.Debugln("Using URL:", response.Info.URL)
6153 return &response.Info, response.Info.URL, nil
6254 }
+0
-20
websocket_utils.go less more
0 package slack
1
2 import (
3 "net"
4 "net/url"
5 )
6
7 var portMapping = map[string]string{"ws": "80", "wss": "443"}
8
9 func websocketizeURLPort(orig string) (string, error) {
10 urlObj, err := url.ParseRequestURI(orig)
11 if err != nil {
12 return "", err
13 }
14 _, _, err = net.SplitHostPort(urlObj.Host)
15 if err != nil {
16 return urlObj.Scheme + "://" + urlObj.Host + ":" + portMapping[urlObj.Scheme] + urlObj.Path, nil
17 }
18 return orig, nil
19 }