Added support for URLs with prefix
Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
+10
@@ -30,6 +30,16 @@ describe('createConfluenceVariables', () => {
|
||||
expect(titleWithSpaces).toEqual('Page Title');
|
||||
});
|
||||
|
||||
it('should return values for Confluence Url with prefix', () => {
|
||||
const url =
|
||||
'https://confluence.example.com/prefix/display/PREFIXSPACEKEY/Prefix+Page+Title';
|
||||
const { spacekey, title, titleWithSpaces } = createConfluenceVariables(url);
|
||||
|
||||
expect(spacekey).toEqual('PREFIXSPACEKEY');
|
||||
expect(title).toEqual('Prefix+Page+Title');
|
||||
expect(titleWithSpaces).toEqual('Prefix Page Title');
|
||||
});
|
||||
|
||||
it('should return values for Confluence Cloud Url', () => {
|
||||
const url =
|
||||
'https://example.atlassian.net/wiki/spaces/CLOUDSPACEKEY/pages/1234567/Cloud+Page+Title';
|
||||
|
||||
+6
@@ -197,6 +197,12 @@ export const createConfluenceVariables = (url: string) => {
|
||||
title = params.pathname.split('/')[3];
|
||||
titleWithSpaces = title?.replace(/\+/g, ' ');
|
||||
return { spacekey, title, titleWithSpaces };
|
||||
} else if (params.pathname.split('/')[2] === 'display') {
|
||||
// https://confluence.example.com/prefix/display/SPACEKEY/Page+Title
|
||||
spacekey = params.pathname.split('/')[3];
|
||||
title = params.pathname.split('/')[4];
|
||||
titleWithSpaces = title?.replace(/\+/g, ' ');
|
||||
return { spacekey, title, titleWithSpaces };
|
||||
} else if (params.pathname.split('/')[2] === 'spaces') {
|
||||
// https://example.atlassian.net/wiki/spaces/SPACEKEY/pages/1234567/Page+Title
|
||||
spacekey = params.pathname.split('/')[3];
|
||||
|
||||
Reference in New Issue
Block a user