Skip to content

Commit 8cae5e9

Browse files
committed
Add debug logging for URL processing in attachment downloader
- Added debug logs to trace `<a>` and `<img>` tag processing in `bodyHTML` parsing. - Included logs for authenticated URL lookups and usage in `getAuthenticatedUrl`.
1 parent 9bcaac5 commit 8cae5e9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/github/junie/attachment-downloader.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function extractAuthenticatedUrls(bodyHTML: string): Map<string, string> {
2828
for (const match of bodyHTML.matchAll(linkPattern)) {
2929
const fullUrl = match[1];
3030
const baseUrl = fullUrl.split('?')[0]; // Remove query params to get base URL
31+
console.log(`[DEBUG] Found <a> tag: baseUrl="${baseUrl}", fullUrl="${fullUrl}"`);
3132
urlMap.set(baseUrl, fullUrl);
3233
}
3334

@@ -36,6 +37,7 @@ function extractAuthenticatedUrls(bodyHTML: string): Map<string, string> {
3637
for (const match of bodyHTML.matchAll(imgPattern)) {
3738
const fullUrl = match[1];
3839
const baseUrl = fullUrl.split('?')[0];
40+
console.log(`[DEBUG] Found <img> tag: baseUrl="${baseUrl}", fullUrl="${fullUrl}"`);
3941
urlMap.set(baseUrl, fullUrl);
4042
}
4143

@@ -113,7 +115,12 @@ export async function downloadAttachmentsAndRewriteText(text: string, bodyHTML:
113115
// Helper function to get authenticated URL if available, otherwise return original
114116
const getAuthenticatedUrl = (url: string): string => {
115117
const baseUrl = url.split('?')[0]; // Remove any existing query params
116-
return authenticatedUrls.get(baseUrl) || url;
118+
const authenticatedUrl = authenticatedUrls.get(baseUrl);
119+
console.log(`[DEBUG] Looking up: "${url}" -> baseUrl: "${baseUrl}" -> found: ${authenticatedUrl ? 'YES' : 'NO'}`);
120+
if (authenticatedUrl) {
121+
console.log(`[DEBUG] Using authenticated URL: "${authenticatedUrl}"`);
122+
}
123+
return authenticatedUrl || url;
117124
};
118125

119126
// Handle HTML image tags with user-attachments URLs

0 commit comments

Comments
 (0)