@remix-run/router 0.0.0-experimental-114cf0b7 → 0.0.0-experimental-e7ce8959
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.cjs.js +25 -15
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +1 -0
- package/dist/router.js +25 -15
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +25 -15
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/history.ts +0 -4
- package/package.json +1 -1
- package/router.ts +17 -8
- package/utils.ts +28 -14
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-e7ce8959
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -496,10 +496,6 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
|
|
|
496
496
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=878297
|
|
497
497
|
let base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
498
498
|
let href = typeof to === "string" ? to : createPath(to);
|
|
499
|
-
// Treating this as a full URL will strip any trailing spaces so we need to
|
|
500
|
-
// pre-encode them since they might be part of a matching splat param from
|
|
501
|
-
// an ancestor route
|
|
502
|
-
href = href.replace(/ $/, "%20");
|
|
503
499
|
invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
|
|
504
500
|
return new URL(href, base);
|
|
505
501
|
}
|
|
@@ -756,14 +752,14 @@ function matchRoutes(routes, locationArg, basename) {
|
|
|
756
752
|
rankRouteBranches(branches);
|
|
757
753
|
let matches = null;
|
|
758
754
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
755
|
+
matches = matchRouteBranch(branches[i],
|
|
759
756
|
// Incoming pathnames are generally encoded from either window.location
|
|
760
757
|
// or from router.navigate, but we want to match against the unencoded
|
|
761
758
|
// paths in the route definitions. Memory router locations won't be
|
|
762
759
|
// encoded here but there also shouldn't be anything to decode so this
|
|
763
760
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
764
761
|
// history-aware.
|
|
765
|
-
|
|
766
|
-
matches = matchRouteBranch(branches[i], decoded);
|
|
762
|
+
safelyDecodeURI(pathname));
|
|
767
763
|
}
|
|
768
764
|
return matches;
|
|
769
765
|
}
|
|
@@ -1042,7 +1038,7 @@ function matchPath(pattern, pathname) {
|
|
|
1042
1038
|
if (isOptional && !value) {
|
|
1043
1039
|
memo[paramName] = undefined;
|
|
1044
1040
|
} else {
|
|
1045
|
-
memo[paramName] = (value || ""
|
|
1041
|
+
memo[paramName] = safelyDecodeURIComponent(value || "", paramName);
|
|
1046
1042
|
}
|
|
1047
1043
|
return memo;
|
|
1048
1044
|
}, {});
|
|
@@ -1094,14 +1090,22 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1094
1090
|
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
|
|
1095
1091
|
return [matcher, params];
|
|
1096
1092
|
}
|
|
1097
|
-
function
|
|
1093
|
+
function safelyDecodeURI(value) {
|
|
1098
1094
|
try {
|
|
1099
|
-
return value
|
|
1095
|
+
return decodeURI(value);
|
|
1100
1096
|
} catch (error) {
|
|
1101
1097
|
warning(false, "The URL path \"" + value + "\" could not be decoded because it is is a " + "malformed URL segment. This is probably due to a bad percent " + ("encoding (" + error + ")."));
|
|
1102
1098
|
return value;
|
|
1103
1099
|
}
|
|
1104
1100
|
}
|
|
1101
|
+
function safelyDecodeURIComponent(value, paramName) {
|
|
1102
|
+
try {
|
|
1103
|
+
return decodeURIComponent(value);
|
|
1104
|
+
} catch (error) {
|
|
1105
|
+
warning(false, "The value for the URL param \"" + paramName + "\" will not be decoded because" + (" the string \"" + value + "\" is a malformed URL segment. This is probably") + (" due to a bad percent encoding (" + error + ")."));
|
|
1106
|
+
return value;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1105
1109
|
|
|
1106
1110
|
/**
|
|
1107
1111
|
* @private
|
|
@@ -3271,7 +3275,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3271
3275
|
}
|
|
3272
3276
|
// Config driven behavior flags
|
|
3273
3277
|
let future = _extends({
|
|
3274
|
-
v7_relativeSplatPath: false
|
|
3278
|
+
v7_relativeSplatPath: false,
|
|
3279
|
+
v7_throwAbortReason: false
|
|
3275
3280
|
}, opts ? opts.future : null);
|
|
3276
3281
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, undefined, manifest);
|
|
3277
3282
|
|
|
@@ -3494,8 +3499,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3494
3499
|
requestContext
|
|
3495
3500
|
});
|
|
3496
3501
|
if (request.signal.aborted) {
|
|
3497
|
-
|
|
3498
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3502
|
+
throwStaticHandlerAbortedError(request, isRouteRequest, future);
|
|
3499
3503
|
}
|
|
3500
3504
|
}
|
|
3501
3505
|
if (isRedirectResult(result)) {
|
|
@@ -3613,8 +3617,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3613
3617
|
requestContext
|
|
3614
3618
|
}))]);
|
|
3615
3619
|
if (request.signal.aborted) {
|
|
3616
|
-
|
|
3617
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3620
|
+
throwStaticHandlerAbortedError(request, isRouteRequest, future);
|
|
3618
3621
|
}
|
|
3619
3622
|
|
|
3620
3623
|
// Process and commit output from loaders
|
|
@@ -3659,6 +3662,13 @@ function getStaticContextFromError(routes, context, error) {
|
|
|
3659
3662
|
});
|
|
3660
3663
|
return newContext;
|
|
3661
3664
|
}
|
|
3665
|
+
function throwStaticHandlerAbortedError(request, isRouteRequest, future) {
|
|
3666
|
+
if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
|
|
3667
|
+
throw request.signal.reason;
|
|
3668
|
+
}
|
|
3669
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3670
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3671
|
+
}
|
|
3662
3672
|
function isSubmissionNavigation(opts) {
|
|
3663
3673
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== undefined);
|
|
3664
3674
|
}
|