Skip to content

fix(wujie): simplify URL rewrite with direct new URL(url, placeholder) - #269

Merged
Gaubee merged 1 commit into
mainfrom
fix/wujie-url-rewrite-v2
Jan 21, 2026
Merged

Gaubee merged 1 commit into
mainfrom
fix/wujie-url-rewrite-v2

Conversation

@Gaubee

@Gaubee Gaubee commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Previous fix was overly complex, manually extracting pathname/search/hash.

Fix

Simplified to just:

const normalized = new URL(req.url, PLACEHOLDER_ORIGIN);
const rewrittenUrl = normalized.href.replace(PLACEHOLDER_ORIGIN, targetBase);

Benefits:

  • If URL has its own host (e.g., CDN), it's preserved automatically
  • No manual parsing of pathname/search/hash
  • 5 lines vs 14 lines

@Gaubee
Gaubee merged commit 9d3a363 into main Jan 21, 2026
5 checks passed
@Gaubee
Gaubee deleted the fix/wujie-url-rewrite-v2 branch January 21, 2026 10:30
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.

1 participant