fix: trim trailing whitespace from baseURL in withBase#545
fix: trim trailing whitespace from baseURL in withBase#545guoyangzhen wants to merge 1 commit intounjs:mainfrom
Conversation
When baseURL ends with whitespace or control characters (e.g. \r, \n, \t) from .env parsing mistakes, the URL merging breaks because withoutTrailingSlash only checks for '/' at the end. Fix: trim trailing whitespace from base URL before processing in withBase(). Fixes unjs#530
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThe entire URL utilities module is being removed, eliminating URL construction helpers (joinURL, withBase, withQuery) and related types. A test case is added to validate that baseURL strings with trailing whitespace or control characters are properly trimmed during URL merging. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Btw did you accidentally delete the entire utils file?
When
baseURLends with whitespace or control characters (e.g.\r,\n,\t) — which can happen from.envparsing mistakes — the URL merging breaks becausewithoutTrailingSlashonly checks for/at the end.Root Cause
The
withBase()function passesbasetowithoutTrailingSlash(), which only strips trailing/. When the base URL has trailing control characters like\r:The browser/URL parser interprets
\ras a line break, causing the path component to be stripped.Fix
Trim trailing whitespace from the base URL before processing in
withBase().Testing
Added tests for
\r\n,\t, and trailing spaces inbaseURL.Fixes #530
Summary by CodeRabbit
Chores
Tests