[MM-41392] Clean path name on browser pushes for subpaths (#1993)
This commit is contained in:
@@ -542,9 +542,10 @@ export class WindowManager {
|
|||||||
|
|
||||||
handleBrowserHistoryPush = (e: IpcMainEvent, viewName: string, pathName: string) => {
|
handleBrowserHistoryPush = (e: IpcMainEvent, viewName: string, pathName: string) => {
|
||||||
const currentView = this.viewManager?.views.get(viewName);
|
const currentView = this.viewManager?.views.get(viewName);
|
||||||
const redirectedViewName = urlUtils.getView(`${currentView?.tab.server.url}${pathName}`, Config.teams)?.name || viewName;
|
const cleanedPathName = pathName.replace(currentView?.tab.server.url.pathname || '', '');
|
||||||
|
const redirectedViewName = urlUtils.getView(`${currentView?.tab.server.url}${cleanedPathName}`, Config.teams)?.name || viewName;
|
||||||
if (this.viewManager?.closedViews.has(redirectedViewName)) {
|
if (this.viewManager?.closedViews.has(redirectedViewName)) {
|
||||||
this.viewManager.openClosedTab(redirectedViewName, `${currentView?.tab.server.url}${pathName}`);
|
this.viewManager.openClosedTab(redirectedViewName, `${currentView?.tab.server.url}${cleanedPathName}`);
|
||||||
}
|
}
|
||||||
let redirectedView = this.viewManager?.views.get(redirectedViewName) || currentView;
|
let redirectedView = this.viewManager?.views.get(redirectedViewName) || currentView;
|
||||||
if (redirectedView !== currentView && redirectedView?.tab.server.name === this.currentServerName && redirectedView?.isLoggedIn) {
|
if (redirectedView !== currentView && redirectedView?.tab.server.name === this.currentServerName && redirectedView?.isLoggedIn) {
|
||||||
@@ -555,8 +556,8 @@ export class WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Special case check for Channels to not force a redirect to "/", causing a refresh
|
// Special case check for Channels to not force a redirect to "/", causing a refresh
|
||||||
if (!(redirectedView !== currentView && redirectedView?.tab.type === TAB_MESSAGING && pathName === '/')) {
|
if (!(redirectedView !== currentView && redirectedView?.tab.type === TAB_MESSAGING && cleanedPathName === '/')) {
|
||||||
redirectedView?.view.webContents.send(BROWSER_HISTORY_PUSH, pathName);
|
redirectedView?.view.webContents.send(BROWSER_HISTORY_PUSH, cleanedPathName);
|
||||||
if (redirectedView) {
|
if (redirectedView) {
|
||||||
this.handleBrowserHistoryButton(e, redirectedView.name);
|
this.handleBrowserHistoryButton(e, redirectedView.name);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user