✨ Feature: global url rewrite#189
Merged
Molunerfinn merged 5 commits intodevfrom Jan 12, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a global URL rewrite feature that allows users to configure regex-based URL transformations on uploaded image URLs. The rewrite happens in the upload lifecycle after the upload completes but before afterUpload plugins execute, ensuring plugins see the rewritten URLs.
Changes:
- Added URL rewrite utility module with configurable regex-based URL transformation
- Refactored URL encoding logic to use native URL constructor with protocol-relative URL support
- Modified getURLFile to handle non-image content types as successful responses
- Exported applyUrlRewriteToImgInfo utility function for external use
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/urlRewrite.ts | New module implementing URL rewrite logic with regex compilation, rule application, and first-match-wins strategy |
| src/utils/common.ts | Refactored handleUrlEncode to use URL constructor and changed getURLFile to treat non-image responses as successful |
| src/types/index.ts | Added IUrlRewriteRule interface and originImgUrl field to IImgInfo |
| src/index.ts | Exported applyUrlRewriteToImgInfo in PicGoUtils namespace |
| src/core/Lifecycle.ts | Integrated URL rewrite into afterUpload lifecycle phase before plugin execution |
| src/i18n/*.ts | Added URL_REWRITE_EMPTY_RESULT translation for empty URL rewrite warning |
| src/tests/unit/urlRewrite.spec.ts | Comprehensive test suite covering edge cases, flags, error handling, and lifecycle integration |
| .github/prompts/*.prompt.md | Added OpenSpec workflow documentation files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.