diff --git a/server/index_data.go b/server/index_data.go index 7f588041..926c0213 100644 --- a/server/index_data.go +++ b/server/index_data.go @@ -83,15 +83,6 @@ func getIndexData(r *http.Request, path string, state *State) *indexData { } data.Channels = channels - referer, err := url.Parse(r.Header.Get("Referer")) - if err == nil { - server, channel := getTabFromPath(referer.EscapedPath()) - if isInChannel(channels, server, channel) { - data.addUsersAndMessages(server, channel, state) - return &data - } - } - server, channel := getTabFromPath(path) if isInChannel(channels, server, channel) { data.addUsersAndMessages(server, channel, state) diff --git a/server/server.go b/server/server.go index c8c8a842..779b88bc 100644 --- a/server/server.go +++ b/server/server.go @@ -181,10 +181,17 @@ func (d *Dispatch) ServeHTTP(w http.ResponseWriter, r *http.Request) { d.upgradeWS(w, r, state) } else if strings.HasPrefix(r.URL.Path, "/init") { + referer, err := url.Parse(r.Header.Get("Referer")) + if err != nil { + fail(w, http.StatusInternalServerError) + return + } + state := d.handleAuth(w, r, true, true) - data := getIndexData(r, "/", state) + data := getIndexData(r, referer.EscapedPath(), state) writeJSON(w, r, data) + } else { d.serveFiles(w, r) }