diff --git a/app/utils/deep_link/index.ts b/app/utils/deep_link/index.ts index 04dc46095..c4ec593de 100644 --- a/app/utils/deep_link/index.ts +++ b/app/utils/deep_link/index.ts @@ -169,16 +169,10 @@ export function parseDeepLink(deepLinkUrl: string): DeepLinkWithData { 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); + 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; - const data: DeepLinkWithData['data'] = {serverUrl, teamName: '', id}; - - if (route) { - data.route = route.join('/'); - } - - return {type: DeepLink.Plugin, url: deepLinkUrl, data}; + 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/test.ts b/app/utils/url/test.ts index 774c399a0..9e8f55af8 100644 --- a/app/utils/url/test.ts +++ b/app/utils/url/test.ts @@ -456,13 +456,21 @@ describe('UrlUtils', () => { expected: null, }, { - name: 'should not match plugin path without a route', + 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: null, + expected: { + data: { + id: 'abc', + route: undefined, + serverUrl: URL_PATH_NO_PROTOCOL, + teamName: '', + }, + type: DeepLinkType.Plugin, + }, }, ];