Add: blacklist in transform, fix env issue in single download#401
Add: blacklist in transform, fix env issue in single download#401
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a blacklist feature to exclude unwanted images from the image picker by using URL transform rules, and fixes an environment handling issue in the single download functionality.
Changes:
- Added blacklist functionality to URL transform rules where setting replacement to "-" excludes matching URLs
- Fixed missing
expandEnvcall insingleDownloadfunction - Fixed ext property handling to include dot prefix consistently
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/url-map.js | Implements blacklist logic by returning empty string when replacement is "-" |
| src/lib/image-util.js | Adds transformURL check in isImage to filter blacklisted images |
| src/content.js | Filters out blacklisted URLs (empty strings) in getImages |
| src/picker.js | Fixes ext property to include dot prefix for consistency |
| src/background.js | Adds missing expandEnv call and fixes ext property in singleDownload |
| README.md | Documents the new blacklist feature with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| base: image.data && image.data.filename, | ||
| alt: image.alt, | ||
| ext: image.data && image.data.ext | ||
| ext: image.data?.ext ? `.${image.data.ext}` : null |
There was a problem hiding this comment.
For consistency with the rest of the codebase and with background.js line 638, consider using undefined instead of null as the fallback value when ext is not available. This maintains consistency with how other optional properties (like base and alt) are handled.
| ext: image.data?.ext ? `.${image.data.ext}` : null | |
| ext: image.data?.ext ? `.${image.data.ext}` : undefined |
src/lib/image-util.js
Outdated
| if (node.src && !transformURL(node.src)) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
This blacklist check in isImage prevents extraction of valid URLs from elements that have a blacklisted src attribute. For example, if an img element has a blacklisted thumbnail in src but a valid full-size image in srcset, the entire element will be rejected and the srcset URL will never be extracted. The blacklist filtering should only happen during URL extraction in content.js (lines 86-88) where individual URLs are filtered, not at the element level. Remove this check from isImage.
| if (node.src && !transformURL(node.src)) { | |
| return false; | |
| } |
Fixes #392