Skip to content

Commit

Permalink
Merge pull request #7785 from mattermost/MM-56592-plugin-deeplink
Browse files Browse the repository at this point in the history
MM-56592: Remove deeplink for plugins
  • Loading branch information
sbishel authored Jan 26, 2024
2 parents 05e7550 + 7be7e5f commit 67a226e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 77 deletions.
1 change: 0 additions & 1 deletion app/constants/deep_linking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const DeepLinkType = {
GroupMessage: 'gm',
Invalid: 'invalid',
Permalink: 'permalink',
Plugin: 'plugin',
Redirect: '_redirect',
} as const;

Expand Down
13 changes: 0 additions & 13 deletions app/utils/deep_link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
TEAM_NAME_PATH_PATTERN,
IDENTIFIER_PATH_PATTERN,
ID_PATH_PATTERN,
PLUGIN_ID_PATH_PATTERN,
} from '@utils/url/path';

import {removeProtocol} from '../url';
Expand Down Expand Up @@ -109,12 +108,6 @@ export async function handleDeepLink(deepLinkUrl: string, intlShape?: IntlShape,
showPermalink(existingServerUrl, deepLinkData.teamName, deepLinkData.postId);
break;
}
case DeepLink.Plugin: {
// https://mattermost.atlassian.net/browse/MM-49846
// const deepLinkData = parsed.data as DeepLinkPlugin;
// showModal('PluginInternal', deepLinkData.id, {link: location});
break;
}
}
return {error: false};
} catch (error) {
Expand Down Expand Up @@ -168,12 +161,6 @@ export function parseDeepLink(deepLinkUrl: string): DeepLinkWithData {
const {params: {serverUrl, teamName, postId}} = permalinkMatch;
return {type: DeepLink.Permalink, url: deepLinkUrl, data: {serverUrl, teamName, postId}};
}

const pluginMatch = match<{serverUrl: string; id: string; route?: string}>(`:serverUrl(.*)/plugins/:id(${PLUGIN_ID_PATH_PATTERN})/:route(.*)?`)(url);
if (pluginMatch) {
const {params: {serverUrl, id, route}} = pluginMatch;
return {type: DeepLink.Plugin, url: deepLinkUrl, data: {serverUrl, teamName: '', id, route}};
}
} catch (err) {
// do nothing just return invalid deeplink
}
Expand Down
1 change: 0 additions & 1 deletion app/utils/url/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See LICENSE.txt for license information.

export const ID_PATH_PATTERN = '[a-z0-9]{26}';
export const PLUGIN_ID_PATH_PATTERN = '[a-zA-Z0-9-_.]{3,190}';

// This should cover:
// - Team name (lowercase english characters, numbers or -)
Expand Down
64 changes: 2 additions & 62 deletions app/utils/url/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,74 +404,14 @@ describe('UrlUtils', () => {
expected: null,
},
{
name: 'should match plugin path on a Server hosted in a Subpath',
name: 'should not match plugin path',
input: {
url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/com.acme.abc-test/api/testroute',
serverURL: SERVER_WITH_SUBPATH,
siteURL: SERVER_WITH_SUBPATH,
},
expected: {
data: {
id: 'com.acme.abc-test',
route: 'api/testroute',
serverUrl: URL_PATH_NO_PROTOCOL,
teamName: '',
},
type: DeepLinkType.Plugin,
},
},
{
name: 'should match plugin path with single-level route',
input: {
url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_ab/testroute',
serverURL: SERVER_WITH_SUBPATH,
siteURL: SERVER_WITH_SUBPATH,
},
expected: {
data: {
id: 'abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_ab',
route: 'testroute',
serverUrl: URL_PATH_NO_PROTOCOL,
teamName: '',
},
type: DeepLinkType.Plugin,
},
},
{
name: 'should not match plugin path with invalid plugin id len=2',
input: {
url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/ab/api/testroute',
serverURL: SERVER_WITH_SUBPATH,
siteURL: SERVER_WITH_SUBPATH,
},
expected: null,
},
{
name: 'should not match plugin path with invalid plugin id len=191',
input: {
url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc_abc/api/testroute',
url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/abc/api/testroute',
serverURL: SERVER_WITH_SUBPATH,
siteURL: SERVER_WITH_SUBPATH,
},
expected: null,
},
{
name: 'should match plugin path without a route',
input: {
url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/abc',
serverURL: SERVER_WITH_SUBPATH,
siteURL: SERVER_WITH_SUBPATH,
},
expected: {
data: {
id: 'abc',
route: undefined,
serverUrl: URL_PATH_NO_PROTOCOL,
teamName: '',
},
type: DeepLinkType.Plugin,
},
},
];

for (const test of tests) {
Expand Down

0 comments on commit 67a226e

Please sign in to comment.