Skip to content

Commit 22129ea

Browse files
Make -ApiVersion prefixing idempotent in Invoke-ConfluenceRestMethod
When -ApiVersion was combined with an -ApiEndpoint that already carries the /wiki/... root, the version prefix was prepended again, producing a doubled path (e.g. /wiki/api/v2/wiki/api/v2/spaces). Skip prefixing for endpoints that are already absolute (full URL or /wiki/*) so both documented usage styles - a relative path with -ApiVersion, or a full /wiki path without it - work safely (review thread on Invoke-ConfluenceRestMethod L80).
1 parent 65f1ffb commit 22129ea

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/functions/public/API/Invoke-ConfluenceRestMethod.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ function Invoke-ConfluenceRestMethod {
7575
}
7676

7777
# Resolve a relative endpoint against the internal v1/v2 map when a version is given.
78-
if ($ApiVersion -and $ApiEndpoint -notmatch '^https?://') {
78+
# An endpoint that is already absolute - a full URL, or one that already carries the
79+
# /wiki/... root - is used as-is, so combining -ApiVersion with an already-versioned path
80+
# does not double the prefix (e.g. /wiki/api/v2/wiki/api/v2/spaces).
81+
if ($ApiVersion -and $ApiEndpoint -notmatch '^https?://' -and $ApiEndpoint -notlike '/wiki/*') {
7982
$ApiEndpoint = '{0}/{1}' -f $script:Confluence.ApiPaths[$ApiVersion], $ApiEndpoint.TrimStart('/')
8083
}
8184

0 commit comments

Comments
 (0)