github Effect-TS/effect @effect/platform@0.55.6

Patch Changes

  • #2903 799aa20 Thanks @rocwang! - # Make baseUrl() more defensive in @effect/platform

    Sometimes, 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 valid location. This could
    break baseUrl(), which is called by makeUrl().

    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 if location.orign and location.pathname are available before accessing them.

  • Updated dependencies [8c5d280, 6ba6d26, cd7496b, 3f28bf2, 5817820, 349a036]:

    • effect@3.2.9
    • @effect/schema@0.67.19

Don't miss a new effect release

NewReleases is sending notifications on new releases.