Skip to content

Commit c0f1b98

Browse files
authored
Improved absolute redirect url detection in actions/loaders (#9829)
1 parent 7951edc commit c0f1b98

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
- latin-1
9797
- lequangdongg
9898
- liuhanqu
99+
- lkwr
99100
- lopezac
100101
- lordofthecactus
101102
- loun4

packages/router/__tests__/router-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11363,6 +11363,8 @@ describe("a router", () => {
1136311363
"https://remix.run/blog",
1136411364
"//remix.run/blog",
1136511365
"app://whatever",
11366+
11367+
"web+remix:whatever",
1136611368
];
1136711369

1136811370
for (let url of urls) {

packages/router/router.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,8 +2832,7 @@ async function callLoaderOrAction(
28322832
"Redirects returned/thrown from loaders/actions must have a Location header"
28332833
);
28342834

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

28382837
// Support relative routing in internal redirects
28392838
if (!isAbsolute) {

0 commit comments

Comments
 (0)