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 = {
621621 location : undefined ,
622622} ;
623623
624+ const ABSOLUTE_URL_REGEX = / ^ (?: [ a - z ] [ a - z 0 - 9 + . - ] * : | \/ \/ ) / i;
625+
624626const isBrowser =
625627 typeof window !== "undefined" &&
626628 typeof window . document !== "undefined" &&
@@ -1915,8 +1917,12 @@ export function createRouter(init: RouterInit): Router {
19151917 "Expected a location on the redirect navigation"
19161918 ) ;
19171919
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+ ) {
19201926 let newOrigin = init . history . createURL ( redirect . location ) . origin ;
19211927 if ( window . location . origin !== newOrigin ) {
19221928 if ( replace ) {
@@ -3093,10 +3099,8 @@ async function callLoaderOrAction(
30933099 "Redirects returned/thrown from loaders/actions must have a Location header"
30943100 ) ;
30953101
3096- let isAbsolute = / ^ (?: [ a - z ] [ a - z 0 - 9 + . - ] * : | \/ \/ ) / i. test ( location ) ;
3097-
30983102 // Support relative routing in internal redirects
3099- if ( ! isAbsolute ) {
3103+ if ( ! ABSOLUTE_URL_REGEX . test ( location ) ) {
31003104 let activeMatches = matches . slice ( 0 , matches . indexOf ( match ) + 1 ) ;
31013105 let routePathnames = getPathContributingMatches ( activeMatches ) . map (
31023106 ( match ) => match . pathnameBase
You can’t perform that action at this time.
0 commit comments