# Fix: Preserve /wiki context when downloading attachments from Confluence Cloud#94
Draft
DreadedTuba wants to merge 1 commit intopchuri:mainfrom
Draft
# Fix: Preserve /wiki context when downloading attachments from Confluence Cloud#94DreadedTuba wants to merge 1 commit intopchuri:mainfrom
DreadedTuba wants to merge 1 commit intopchuri:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Preserve /wiki context when downloading attachments from Confluence Cloud
Problem
Attachment downloads from Confluence Cloud were failing with 404 errors. When Confluence Cloud returns relative download paths in attachment metadata (like
/download/attachments/6141247564/image.png), they need to be appended to the correct base URL including the/wikiprefix.The
toAbsoluteUrl()method was incorrectly dropping thewebUrlPrefix, resulting in broken URLs being constructed.Root Cause
In
lib/confluence-client.js, thetoAbsoluteUrl()method was not considering thewebUrlPrefixwhen building absolute URLs for download paths. This caused relative paths to lose the/wikicontext they need on Confluence Cloud instances.Before (broken):
After (fixed):
Solution
Modified
toAbsoluteUrl()to detect relative paths starting with/download/or/plugins/and prepend thewebUrlPrefix(typically/wikifor Cloud instances) before building the absolute URL.Changes
lib/confluence-client.jstoAbsoluteUrl()webUrlPrefixTesting
✅ Manual Testing:
confluence attachments <PAGE_ID>to list attachmentsconfluence attachments <PAGE_ID> --download --dest ./test-downloads --limit 2✅ Automated Testing:
npm test- all tests passed (exit code 0)Impact
References
/wiki/download/paths while self-hosted uses/download/Checklist