Skip to content

Commit c0b3674

Browse files
author
Al Manning
committed
[Confluence] Error publishing to site URL with param #4723
1 parent 14bfdef commit c0b3674

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/publish/confluence/confluence-helper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ export const tokenFilterOut = (
123123
};
124124

125125
export const confluenceParentFromString = (url: string): ConfluenceParent => {
126-
const match = url.match(
126+
let toMatch = url;
127+
const urlNoParamsList = url?.split("?");
128+
129+
if (urlNoParamsList.length === 2) {
130+
toMatch = urlNoParamsList[0] ?? url;
131+
}
132+
133+
const match = toMatch.match(
127134
/^https.*?wiki\/spaces\/(?:(~?\w+)|(~?\w+)\/overview|(~?\w+)\/pages\/(\d+).*)$/
128135
);
129136
if (match) {

tests/unit/confluence.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,17 @@ const runConfluenceParentFromString = () => {
310310
assertEquals(expected, result);
311311
});
312312

313+
test("confluenceParentFromString_valid_spaces_pages_with_homepage", async () => {
314+
const url =
315+
"https://allenmanning.atlassian.net/wiki/spaces/~557058634d59d0949841909bb13093ab41d0c5/overview?homepageId=65617";
316+
const result = confluenceParentFromString(url);
317+
const expected: ConfluenceParent = {
318+
space: "~557058634d59d0949841909bb13093ab41d0c5",
319+
parent: undefined,
320+
};
321+
assertEquals(expected, result);
322+
});
323+
313324
test("confluenceParentFromString_valid_noParent", async () => {
314325
const url = "https://test.atlassian.net/wiki/spaces/QUARTOCONF";
315326
const result = confluenceParentFromString(url);

0 commit comments

Comments
 (0)