@remix-run/router 1.3.3-pre.0 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/router.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.3.3-pre.0
2
+ * @remix-run/router v1.3.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2508,9 +2508,10 @@ function createRouter(init) {
2508
2508
  invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an absolute external redirect that goes to a new origin
2509
2509
 
2510
2510
  if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
2511
- let newOrigin = init.history.createURL(redirect.location).origin;
2511
+ let url = init.history.createURL(redirect.location);
2512
+ let isDifferentBasename = stripBasename(url.pathname, init.basename || "/") == null;
2512
2513
 
2513
- if (window.location.origin !== newOrigin) {
2514
+ if (window.location.origin !== url.origin || isDifferentBasename) {
2514
2515
  if (replace) {
2515
2516
  window.location.replace(redirect.location);
2516
2517
  } else {
@@ -3545,13 +3546,14 @@ async function callLoaderOrAction(type, request, match, matches, basename, isSta
3545
3546
 
3546
3547
  location = createPath(resolvedLocation);
3547
3548
  } else if (!isStaticRequest) {
3548
- // Strip off the protocol+origin for same-origin absolute redirects.
3549
- // If this is a static reques, we can let it go back to the browser
3550
- // as-is
3549
+ // Strip off the protocol+origin for same-origin + same-basename absolute
3550
+ // redirects. If this is a static request, we can let it go back to the
3551
+ // browser as-is
3551
3552
  let currentUrl = new URL(request.url);
3552
3553
  let url = location.startsWith("//") ? new URL(currentUrl.protocol + location) : new URL(location);
3554
+ let isSameBasename = stripBasename(url.pathname, basename) != null;
3553
3555
 
3554
- if (url.origin === currentUrl.origin) {
3556
+ if (url.origin === currentUrl.origin && isSameBasename) {
3555
3557
  location = url.pathname + url.search + url.hash;
3556
3558
  }
3557
3559
  } // Don't process redirects in the router during static requests requests.