Handle channel names ending with a slash better

This commit is contained in:
Ken-Håvard Lieng 2017-06-13 04:25:59 +02:00
parent f03b30eff6
commit 0f5c3b57d2
8 changed files with 96 additions and 40 deletions

View file

@ -66,13 +66,13 @@ func (h *wsHandler) init(r *http.Request) {
h.session.numWS(), "WebSocket connections")
channels := h.session.user.GetChannels()
path := r.URL.Query().Get("path")
params := strings.Split(strings.Trim(path, "/"), "/")
tabServer, tabChannel := parseTabCookie(r, path)
path := r.URL.EscapedPath()[3:]
pathServer, pathChannel := getTabFromPath(path)
cookieServer, cookieChannel := parseTabCookie(r, path)
for _, channel := range channels {
if (len(params) == 2 && channel.Server == params[0] && channel.Name == params[1]) ||
(channel.Server == tabServer && channel.Name == tabChannel) {
if (channel.Server == pathServer && channel.Name == pathChannel) ||
(channel.Server == cookieServer && channel.Name == cookieChannel) {
continue
}