@remix-run/router 0.0.0-experimental-d90c8fb3 → 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 -11
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +1 -0
- package/dist/router.js +25 -11
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +25 -11
- 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/package.json +1 -1
- package/router.ts +17 -8
- package/utils.ts +28 -14
package/dist/router.d.ts
CHANGED
|
@@ -487,6 +487,7 @@ export declare const UNSAFE_DEFERRED_SYMBOL: unique symbol;
|
|
|
487
487
|
*/
|
|
488
488
|
export interface StaticHandlerFutureConfig {
|
|
489
489
|
v7_relativeSplatPath: boolean;
|
|
490
|
+
v7_throwAbortReason: boolean;
|
|
490
491
|
}
|
|
491
492
|
export interface CreateStaticHandlerOptions {
|
|
492
493
|
basename?: string;
|
package/dist/router.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
|
*
|
|
@@ -523,14 +523,14 @@ function matchRoutes(routes, locationArg, basename) {
|
|
|
523
523
|
rankRouteBranches(branches);
|
|
524
524
|
let matches = null;
|
|
525
525
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
526
|
+
matches = matchRouteBranch(branches[i],
|
|
526
527
|
// Incoming pathnames are generally encoded from either window.location
|
|
527
528
|
// or from router.navigate, but we want to match against the unencoded
|
|
528
529
|
// paths in the route definitions. Memory router locations won't be
|
|
529
530
|
// encoded here but there also shouldn't be anything to decode so this
|
|
530
531
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
531
532
|
// history-aware.
|
|
532
|
-
|
|
533
|
-
matches = matchRouteBranch(branches[i], decoded);
|
|
533
|
+
safelyDecodeURI(pathname));
|
|
534
534
|
}
|
|
535
535
|
return matches;
|
|
536
536
|
}
|
|
@@ -789,7 +789,7 @@ function matchPath(pattern, pathname) {
|
|
|
789
789
|
if (isOptional && !value) {
|
|
790
790
|
memo[paramName] = undefined;
|
|
791
791
|
} else {
|
|
792
|
-
memo[paramName] = (value || ""
|
|
792
|
+
memo[paramName] = safelyDecodeURIComponent(value || "", paramName);
|
|
793
793
|
}
|
|
794
794
|
return memo;
|
|
795
795
|
}, {});
|
|
@@ -841,14 +841,22 @@ function compilePath(path, caseSensitive, end) {
|
|
|
841
841
|
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
|
|
842
842
|
return [matcher, params];
|
|
843
843
|
}
|
|
844
|
-
function
|
|
844
|
+
function safelyDecodeURI(value) {
|
|
845
845
|
try {
|
|
846
|
-
return value
|
|
846
|
+
return decodeURI(value);
|
|
847
847
|
} catch (error) {
|
|
848
848
|
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 + ")."));
|
|
849
849
|
return value;
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
+
function safelyDecodeURIComponent(value, paramName) {
|
|
853
|
+
try {
|
|
854
|
+
return decodeURIComponent(value);
|
|
855
|
+
} catch (error) {
|
|
856
|
+
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 + ")."));
|
|
857
|
+
return value;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
852
860
|
/**
|
|
853
861
|
* @private
|
|
854
862
|
*/
|
|
@@ -2814,7 +2822,8 @@ function createStaticHandler(routes, opts) {
|
|
|
2814
2822
|
}
|
|
2815
2823
|
// Config driven behavior flags
|
|
2816
2824
|
let future = _extends({
|
|
2817
|
-
v7_relativeSplatPath: false
|
|
2825
|
+
v7_relativeSplatPath: false,
|
|
2826
|
+
v7_throwAbortReason: false
|
|
2818
2827
|
}, opts ? opts.future : null);
|
|
2819
2828
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, undefined, manifest);
|
|
2820
2829
|
/**
|
|
@@ -3031,8 +3040,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3031
3040
|
requestContext
|
|
3032
3041
|
});
|
|
3033
3042
|
if (request.signal.aborted) {
|
|
3034
|
-
|
|
3035
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3043
|
+
throwStaticHandlerAbortedError(request, isRouteRequest, future);
|
|
3036
3044
|
}
|
|
3037
3045
|
}
|
|
3038
3046
|
if (isRedirectResult(result)) {
|
|
@@ -3146,8 +3154,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3146
3154
|
requestContext
|
|
3147
3155
|
}))]);
|
|
3148
3156
|
if (request.signal.aborted) {
|
|
3149
|
-
|
|
3150
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3157
|
+
throwStaticHandlerAbortedError(request, isRouteRequest, future);
|
|
3151
3158
|
}
|
|
3152
3159
|
// Process and commit output from loaders
|
|
3153
3160
|
let activeDeferreds = new Map();
|
|
@@ -3187,6 +3194,13 @@ function getStaticContextFromError(routes, context, error) {
|
|
|
3187
3194
|
});
|
|
3188
3195
|
return newContext;
|
|
3189
3196
|
}
|
|
3197
|
+
function throwStaticHandlerAbortedError(request, isRouteRequest, future) {
|
|
3198
|
+
if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
|
|
3199
|
+
throw request.signal.reason;
|
|
3200
|
+
}
|
|
3201
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3202
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3203
|
+
}
|
|
3190
3204
|
function isSubmissionNavigation(opts) {
|
|
3191
3205
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== undefined);
|
|
3192
3206
|
}
|