Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ chrome.contextMenus.onClicked.addListener(function (info, tab) {
});

async function downloadImageForFrame(srcUrl, tabId, frameId, format) {
let parsedUrl;
try {
parsedUrl = new URL(srcUrl);
} catch {
console.error('[BACKGROUND] Invalid URL:', srcUrl);
return;
}
if (!['http:', 'https:'].includes(parsedUrl.protocol)) {
console.error('[BACKGROUND] Unsupported URL scheme:', parsedUrl.protocol);
return;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel list if the URL was already validated, i.e. it didn't return early, it should just use the original instead of writing back over it. If that's the case it should just carry the parsedUrl.href property through the rest of the code instead.

let filename = getFileNameFromURL(srcUrl, format);

console.info(`Download request: ${format} format for URL: ${srcUrl}`);
Expand Down
Loading