Patch Changes
-
#2903
799aa20
Thanks @rocwang! - # Make baseUrl() more defensive in @effect/platformSometimes, third party code may patch a missing global
location
to accommodate for non-browser JavaScript
runtimes, e.g. Cloudflare Workers,
Deno. Such patch
might not yield a fully validlocation
. This could
breakbaseUrl()
, which is called bymakeUrl()
.For example, the following code would log
Invalid URL: '/api/v1/users' with base 'NaN'
.import { makeUrl } from "@effect/platform/Http/UrlParams"; globalThis.location = { href: "" }; const url = makeUrl("/api/v1/users", []); // This would log "Invalid URL: '/api/v1/users' with base 'NaN'", // because location.origin + location.pathname return NaN in baseUrl() console.log(url.left.message);
Arguably, this is not an issue of Effect per se, but it's better to be defensive and handle such cases gracefully.
So this change does that by checking iflocation.orign
andlocation.pathname
are available before accessing them. -
Updated dependencies [
8c5d280
,6ba6d26
,cd7496b
,3f28bf2
,5817820
,349a036
]:- effect@3.2.9
- @effect/schema@0.67.19