Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: redirect in --location relative fetch #9150

Merged

Conversation

lucacasonato
Copy link
Member

Before:

$ cat example.ts
console.log(globalThis.location.href);

const res = await fetch("/std/version.ts");
console.log(res.status, res.url);
console.log(await res.text());
$ deno run --location="https://deno.land" --allow-net example.ts
https://deno.land/
error: Uncaught (in promise) TypeError: Invalid base URL.
          throw new TypeError("Invalid base URL.");
                ^
    at new URL (deno:op_crates/web/11_url.js:714:17)
    at fetch (deno:op_crates/fetch/26_fetch.js:1407:29)
    at async file:///Users/lucacasonato/Projects/github.com/denoland/deno/example.ts:3:13

After:

$ cat example.ts
console.log(globalThis.location.href);

const res = await fetch("/std/version.ts");
console.log(res.status, res.url);
console.log(await res.text());
$ deno run --location="https://deno.land" --allow-net example.ts
https://deno.land/
200 https://deno.land/[email protected]/version.ts
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
/** Version of the Deno standard modules
 *
 * Deno std is versioned differently than Deno cli because it is still unstable;
 * the cli's API is stable. In the future when std becomes stable, likely we
 * will match versions with cli as we have in the past.
 */
export const VERSION = "0.83.0";

@lucacasonato lucacasonato force-pushed the location_relative_fetch_redirect_ branch from 22dc2ab to 9941bdb Compare January 18, 2021 12:11
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lucacasonato lucacasonato merged commit 7a30d1a into denoland:master Jan 18, 2021
@lucacasonato lucacasonato deleted the location_relative_fetch_redirect_ branch January 18, 2021 12:59
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.

2 participants