-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logic added for redirecting to subdomains #22944
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ const deriveIsHostMatch = (redirect, currentWindow) => { | |
const redirectIfNecessary = currentWindow => { | ||
// Check if the route matches an absolute cross-domain redirect. | ||
const absoluteCrossDomainRedirects = crossDomainRedirects?.filter( | ||
redirect => !redirect?.catchAll, | ||
redirect => !redirect?.catchAll && !redirect?.isToSubdomain, | ||
); | ||
const absoluteRedirectMatch = absoluteCrossDomainRedirects?.find(redirect => { | ||
const isHostMatch = deriveIsHostMatch(redirect, currentWindow); | ||
|
@@ -58,6 +58,24 @@ const redirectIfNecessary = currentWindow => { | |
catchAllRedirectMatch.dest | ||
}`; | ||
} | ||
|
||
// Check if redirect destination is to a subdomain | ||
const toSubdomainRedirects = crossDomainRedirects?.filter( | ||
redirect => redirect?.isToSubdomain, | ||
); | ||
|
||
const toSubdomainRedirectMatch = toSubdomainRedirects?.find(redirect => { | ||
const isHostMatch = deriveIsHostMatch(redirect, currentWindow); | ||
const currentPathMatchesSubdomainSrc = | ||
currentWindow.location.pathname === redirect.src.toLowerCase(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is going to be problematic. We likely want to call |
||
return isHostMatch && currentPathMatchesSubdomainSrc; | ||
}); | ||
|
||
// Redirect if there is a to subdomain match | ||
if (toSubdomainRedirectMatch) { | ||
// eslint-disable-next-line no-param-reassign | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ESLint disabled here |
||
currentWindow.location.href = `${catchAllRedirectMatch.dest}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels like this should be:
|
||
} | ||
}; | ||
|
||
export default redirectIfNecessary; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESLint disabled here