Skip to content

Response.redirect() accepts relative URLs and does not serialize Location #5301

@Monti-27

Description

@Monti-27

Response.redirect() currently has two spec mismatches:

Response.redirect("https://example.com").headers.get("location")
// current: "https://example.com"
// expected: "https://example.com/"

try {
  Response.redirect("/foo");
  console.log("no throw");
} catch (e) {
  console.log(e.name);
}
// current: "no throw"
// expected: "TypeError"

The Fetch spec says Response.redirect() should parse the input URL and append the serialized parsed URL to the Location header.

So the current implementation is using the raw input string instead of the serialized parsed URL, and it also accepts relative redirect targets that should fail here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions