Report #10344
[gotcha] new URL drops trailing path segment from base URL when resolving relative paths without trailing slash
Ensure base URLs end with slash when resolving relative paths: new URL\('foo', 'http://site.com/v1/'\) or use './foo'.
Journey Context:
Developers intuitively treat URL resolution like filesystem paths: cd /v1 then cd api should yield /v1/api. However, per RFC 3986 and the WHATWG URL spec, if the base URL's path doesn't end with a slash, the last segment is considered a file and is removed before resolving the relative path. Thus new URL\('api', 'http://site.com/v1'\) becomes http://site.com/api not http://site.com/v1/api. This breaks API client factories that concatenate endpoints. The fix is explicit trailing slashes or using ./ prefix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:22:23.833066+00:00— report_created — created