[MM-53056] Force a pathname when checking for deep links (#2748)
This commit is contained in:
parent
1db2828a93
commit
a7c25ee95e
|
@ -13,6 +13,7 @@ jest.mock('common/config', () => ({
|
||||||
jest.mock('common/utils/url', () => ({
|
jest.mock('common/utils/url', () => ({
|
||||||
parseURL: jest.fn(),
|
parseURL: jest.fn(),
|
||||||
isInternalURL: jest.fn(),
|
isInternalURL: jest.fn(),
|
||||||
|
getFormattedPathName: (pathname) => (pathname.length ? pathname : '/'),
|
||||||
}));
|
}));
|
||||||
jest.mock('common/utils/util', () => ({
|
jest.mock('common/utils/util', () => ({
|
||||||
isVersionGreaterThanOrEqualTo: jest.fn(),
|
isVersionGreaterThanOrEqualTo: jest.fn(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {TAB_FOCALBOARD, TAB_MESSAGING, TAB_PLAYBOOKS, MattermostView, getDefault
|
||||||
import MessagingView from 'common/views/MessagingView';
|
import MessagingView from 'common/views/MessagingView';
|
||||||
import FocalboardView from 'common/views/FocalboardView';
|
import FocalboardView from 'common/views/FocalboardView';
|
||||||
import PlaybooksView from 'common/views/PlaybooksView';
|
import PlaybooksView from 'common/views/PlaybooksView';
|
||||||
import {isInternalURL, parseURL} from 'common/utils/url';
|
import {getFormattedPathName, isInternalURL, parseURL} from 'common/utils/url';
|
||||||
import Utils from 'common/utils/util';
|
import Utils from 'common/utils/util';
|
||||||
|
|
||||||
const log = new Logger('ServerManager');
|
const log = new Logger('ServerManager');
|
||||||
|
@ -138,7 +138,7 @@ export class ServerManager extends EventEmitter {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
const server = this.getAllServers().find((server) => {
|
const server = this.getAllServers().find((server) => {
|
||||||
return isInternalURL(parsedURL, server.url, ignoreScheme) && parsedURL.pathname.match(new RegExp(`^${server.url.pathname}(.+)?(/(.+))?$`));
|
return isInternalURL(parsedURL, server.url, ignoreScheme) && getFormattedPathName(parsedURL.pathname).match(new RegExp(`^${server.url.pathname}(.+)?(/(.+))?$`));
|
||||||
});
|
});
|
||||||
if (!server) {
|
if (!server) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -149,7 +149,7 @@ export class ServerManager extends EventEmitter {
|
||||||
views.
|
views.
|
||||||
filter((view) => view && view.type !== TAB_MESSAGING).
|
filter((view) => view && view.type !== TAB_MESSAGING).
|
||||||
forEach((view) => {
|
forEach((view) => {
|
||||||
if (parsedURL.pathname.match(new RegExp(`^${view.url.pathname}(/(.+))?`))) {
|
if (getFormattedPathName(parsedURL.pathname).match(new RegExp(`^${view.url.pathname}(/(.+))?`))) {
|
||||||
selectedView = view;
|
selectedView = view;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,6 +50,7 @@ jest.mock('common/utils/url', () => ({
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getFormattedPathName: (pathname) => (pathname.length ? pathname : '/'),
|
||||||
equalUrlsIgnoringSubpath: jest.fn(),
|
equalUrlsIgnoringSubpath: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import Utils from 'common/utils/util';
|
||||||
import {MattermostServer} from 'common/servers/MattermostServer';
|
import {MattermostServer} from 'common/servers/MattermostServer';
|
||||||
import ServerManager from 'common/servers/serverManager';
|
import ServerManager from 'common/servers/serverManager';
|
||||||
import {MattermostView, TAB_MESSAGING} from 'common/views/View';
|
import {MattermostView, TAB_MESSAGING} from 'common/views/View';
|
||||||
import {parseURL} from 'common/utils/url';
|
import {getFormattedPathName, parseURL} from 'common/utils/url';
|
||||||
|
|
||||||
import {localizeMessage} from 'main/i18nManager';
|
import {localizeMessage} from 'main/i18nManager';
|
||||||
import MainWindow from 'main/windows/mainWindow';
|
import MainWindow from 'main/windows/mainWindow';
|
||||||
|
@ -177,7 +177,7 @@ export class ViewManager {
|
||||||
const parsedURL = parseURL(url)!;
|
const parsedURL = parseURL(url)!;
|
||||||
const view = ServerManager.lookupViewByURL(parsedURL, true);
|
const view = ServerManager.lookupViewByURL(parsedURL, true);
|
||||||
if (view) {
|
if (view) {
|
||||||
const urlWithSchema = `${view.url.origin}${parsedURL.pathname}${parsedURL.search}`;
|
const urlWithSchema = `${view.url.origin}${getFormattedPathName(parsedURL.pathname)}${parsedURL.search}`;
|
||||||
if (this.closedViews.has(view.id)) {
|
if (this.closedViews.has(view.id)) {
|
||||||
this.openClosedView(view.id, urlWithSchema);
|
this.openClosedView(view.id, urlWithSchema);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue