File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @remix-run/router " : patch
3
+ ---
4
+
5
+ Only check for differing origin on absolute URL redirects
Original file line number Diff line number Diff line change @@ -621,6 +621,8 @@ export const IDLE_BLOCKER: BlockerUnblocked = {
621
621
location : undefined ,
622
622
} ;
623
623
624
+ const ABSOLUTE_URL_REGEX = / ^ (?: [ a - z ] [ a - z 0 - 9 + . - ] * : | \/ \/ ) / i;
625
+
624
626
const isBrowser =
625
627
typeof window !== "undefined" &&
626
628
typeof window . document !== "undefined" &&
@@ -1915,8 +1917,12 @@ export function createRouter(init: RouterInit): Router {
1915
1917
"Expected a location on the redirect navigation"
1916
1918
) ;
1917
1919
1918
- // Check if this an external redirect that goes to a new origin
1919
- if ( isBrowser && typeof window ?. location !== "undefined" ) {
1920
+ // Check if this an absolute external redirect that goes to a new origin
1921
+ if (
1922
+ ABSOLUTE_URL_REGEX . test ( redirect . location ) &&
1923
+ isBrowser &&
1924
+ typeof window ?. location !== "undefined"
1925
+ ) {
1920
1926
let newOrigin = init . history . createURL ( redirect . location ) . origin ;
1921
1927
if ( window . location . origin !== newOrigin ) {
1922
1928
if ( replace ) {
@@ -3093,10 +3099,8 @@ async function callLoaderOrAction(
3093
3099
"Redirects returned/thrown from loaders/actions must have a Location header"
3094
3100
) ;
3095
3101
3096
- let isAbsolute = / ^ (?: [ a - z ] [ a - z 0 - 9 + . - ] * : | \/ \/ ) / i. test ( location ) ;
3097
-
3098
3102
// Support relative routing in internal redirects
3099
- if ( ! isAbsolute ) {
3103
+ if ( ! ABSOLUTE_URL_REGEX . test ( location ) ) {
3100
3104
let activeMatches = matches . slice ( 0 , matches . indexOf ( match ) + 1 ) ;
3101
3105
let routePathnames = getPathContributingMatches ( activeMatches ) . map (
3102
3106
( match ) => match . pathnameBase
You can’t perform that action at this time.
0 commit comments