diff --git a/app/constants/deep_linking.ts b/app/constants/deep_linking.ts index f2090831c..4e96eb89e 100644 --- a/app/constants/deep_linking.ts +++ b/app/constants/deep_linking.ts @@ -7,7 +7,6 @@ const DeepLinkType = { GroupMessage: 'gm', Invalid: 'invalid', Permalink: 'permalink', - Plugin: 'plugin', Redirect: '_redirect', } as const; diff --git a/app/utils/deep_link/index.ts b/app/utils/deep_link/index.ts index c4ec593de..4422d7aa3 100644 --- a/app/utils/deep_link/index.ts +++ b/app/utils/deep_link/index.ts @@ -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'; @@ -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) { @@ -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 } diff --git a/app/utils/url/path.ts b/app/utils/url/path.ts index 19a579512..ecae218a6 100644 --- a/app/utils/url/path.ts +++ b/app/utils/url/path.ts @@ -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 -) diff --git a/app/utils/url/test.ts b/app/utils/url/test.ts index 9e8f55af8..ba78b5a0c 100644 --- a/app/utils/url/test.ts +++ b/app/utils/url/test.ts @@ -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', + url: DEEPLINK_URL_ROOT + '/subpath/deepsubpath/plugins/abc/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', - 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) {