Skip to content

Commit

Permalink
fix: Integration test for external redirects (#4627)
Browse files Browse the repository at this point in the history
* Respect redirects to external url destinations

redirect('https://www.google.com/') should go to http://www.google.com/

We should not prepend the request origin to the destination URL if they
are external.

* Sign CLA

* Revert change to router utils

Co-authored-by: Anthony Powell <anthonypowell@hey.com>
  • Loading branch information
2 people authored and kentcdodds committed Dec 15, 2022
1 parent 17e4102 commit 7a4e761
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- camiaei
- CanRau
- ccssmnn
- cephalization
- chaance
- chaukhoa97
- chenc041
Expand Down
13 changes: 13 additions & 0 deletions integration/redirects-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ test.describe("redirects", () => {
return <h1>Page 2</h1>
}
`,
[`app/routes/loader/external.js`]: js`
import { redirect } from "@remix-run/node";
export const loader = () => {
return redirect("https://www.google.com/");
}
`,
},
});

Expand Down Expand Up @@ -186,4 +192,11 @@ test.describe("redirects", () => {
// Loader called twice
await page.waitForSelector(`#count:has-text("3")`);
});

test("redirects to external URLs", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);

await app.waitForNetworkAfter(() => app.goto("/loader/external"));
expect(app.page.url()).toBe("https://www.google.com/");
});
});

0 comments on commit 7a4e761

Please sign in to comment.