Skip to content

Commit

Permalink
Improved absolute redirect url detection in actions/loaders (#9829)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkwr authored Jan 11, 2023
1 parent 7951edc commit c0f1b98
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
- latin-1
- lequangdongg
- liuhanqu
- lkwr
- lopezac
- lordofthecactus
- loun4
Expand Down
2 changes: 2 additions & 0 deletions packages/router/__tests__/router-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11363,6 +11363,8 @@ describe("a router", () => {
"https://remix.run/blog",
"//remix.run/blog",
"app://whatever",
"mailto:[email protected]",
"web+remix:whatever",
];

for (let url of urls) {
Expand Down
3 changes: 1 addition & 2 deletions packages/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2832,8 +2832,7 @@ async function callLoaderOrAction(
"Redirects returned/thrown from loaders/actions must have a Location header"
);

let isAbsolute =
/^[a-z+]+:\/\//i.test(location) || location.startsWith("//");
let isAbsolute = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(location);

// Support relative routing in internal redirects
if (!isAbsolute) {
Expand Down

0 comments on commit c0f1b98

Please sign in to comment.