Skip to content

✨ Feature: global url rewrite#189

Merged
Molunerfinn merged 5 commits intodevfrom
feature-url-rewrite
Jan 12, 2026
Merged

✨ Feature: global url rewrite#189
Molunerfinn merged 5 commits intodevfrom
feature-url-rewrite

Conversation

@Molunerfinn
Copy link
Copy Markdown
Member

No description provided.

@Molunerfinn Molunerfinn changed the title ✨ Feature: global url rewrite ✨ Feature: global url rewrite Jan 12, 2026
@Molunerfinn Molunerfinn requested a review from Copilot January 12, 2026 09:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/utils/common.ts
Comment thread src/utils/common.ts Outdated
@Molunerfinn Molunerfinn merged commit f86ae00 into dev Jan 12, 2026
@Molunerfinn Molunerfinn deleted the feature-url-rewrite branch January 12, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants