update per PR feedback
Demitrious Kelly
6 years ago
26 | 26 |
if !response.Ok {
|
27 | 27 |
return nil, "", response.Error
|
28 | 28 |
}
|
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
|
33 | 29 |
api.Debugln("Using URL:", response.Info.URL)
|
34 | 30 |
return &response.Info, response.Info.URL, nil
|
35 | 31 |
}
|
|
53 | 49 |
if !response.Ok {
|
54 | 50 |
return nil, "", response.Error
|
55 | 51 |
}
|
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
|
60 | 52 |
api.Debugln("Using URL:", response.Info.URL)
|
61 | 53 |
return &response.Info, response.Info.URL, nil
|
62 | 54 |
}
|
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 | |
}
|