Skip to content

Commit 1d7754a

Browse files
committed
Add debug logging to track URL extraction and mapping in attachment downloader
1 parent 0949e2e commit 1d7754a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/github/junie/attachment-downloader.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,28 @@ function extractSignedUrlsFromHtml(bodyHtml: string): Map<string, string> {
5151
// Extract signed URLs from HTML
5252
const signedUrlRegex = /https:\/\/private-user-images\.githubusercontent\.com\/[^"'\s]+\?jwt=[^"'\s]+/g;
5353
const signedUrls = bodyHtml.match(signedUrlRegex) || [];
54+
console.log(`Found ${signedUrls.length} signed URLs in HTML`);
5455

5556
// Extract original URLs from HTML (both in markdown and HTML img tags)
5657
const originalUrlRegex = /https:\/\/github\.com\/user-attachments\/(assets|files)\/[^"'\s)]+/g;
5758
const originalUrls = bodyHtml.match(originalUrlRegex) || [];
59+
console.log(`Found ${originalUrls.length} original attachment URLs in HTML`);
60+
61+
if (originalUrls.length > 0) {
62+
console.log('Original URLs:', originalUrls);
63+
}
64+
if (signedUrls.length > 0 && originalUrls.length === 0) {
65+
console.warn('Found signed URLs but no original URLs - this is unexpected');
66+
console.log('HTML sample:', bodyHtml.substring(0, 300));
67+
}
5868

5969
// Map original URLs to signed URLs (they appear in the same order in HTML)
6070
for (let i = 0; i < Math.min(originalUrls.length, signedUrls.length); i++) {
6171
const original = originalUrls[i];
6272
const signed = signedUrls[i];
6373
if (original && signed) {
6474
urlMap.set(original, signed);
75+
console.log(`Mapped: ${original} -> signed URL`);
6576
}
6677
}
6778

0 commit comments

Comments
 (0)