@remix-run/router
Advanced tools
Comparing version 1.0.2 to 1.0.3-pre.0
# `@remix-run/router` | ||
## 1.0.3-pre.0 | ||
### Patch Changes | ||
- properly support `index` routes with a path in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486)) | ||
- Fix hrefs generated for `createHashRouter` ([#9409](https://github.com/remix-run/react-router/pull/9409)) | ||
- fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477)) | ||
- Ignore pathless layout routes when looking for proper submission `action` function ([#9455](https://github.com/remix-run/react-router/pull/9455)) | ||
- Support `basename` and relative routing in `loader`/`action` redirects ([#9447](https://github.com/remix-run/react-router/pull/9447)) | ||
- Add UMD build for `@remix-run/router` ([#9446](https://github.com/remix-run/react-router/pull/9446)) | ||
- Clean up response APIs for `unstable_createStaticHandler` `queryRoute` ([#9465](https://github.com/remix-run/react-router/pull/9465)) | ||
- Changes to static handler for incorporating into Remix ([#9482](https://github.com/remix-run/react-router/pull/9482)) | ||
## 1.0.2 | ||
@@ -27,4 +40,4 @@ | ||
[rr-docs]: https://reactrouter.com/ | ||
[rr-feature-overview]: https://reactrouter.com/en/v6.4.0/start/overview | ||
[rr-tutorial]: https://reactrouter.com/en/v6.4.0/start/tutorial | ||
[rr-feature-overview]: https://reactrouter.com/en/6.4.0/start/overview | ||
[rr-tutorial]: https://reactrouter.com/en/6.4.0/start/tutorial | ||
[remix-router-readme]: https://github.com/remix-run/react-router/blob/main/packages/router/README.md |
@@ -1,2 +0,2 @@ | ||
import { convertRoutesToDataRoutes } from "./utils"; | ||
import { convertRoutesToDataRoutes, getPathContributingMatches } from "./utils"; | ||
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, TrackedPromise, FormEncType, FormMethod, JsonFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathPattern, RedirectFunction, ShouldRevalidateFunction, Submission, } from "./utils"; | ||
@@ -8,2 +8,2 @@ export { AbortedDeferredError, ErrorResponse, defer, generatePath, getToPathname, invariant, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, resolvePath, resolveTo, stripBasename, warning, } from "./utils"; | ||
/** @internal */ | ||
export { convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes }; | ||
export { convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, }; |
@@ -286,3 +286,27 @@ import type { Location, Path, To } from "./history"; | ||
* @private | ||
* | ||
* When processing relative navigation we want to ignore ancestor routes that | ||
* do not contribute to the path, such that index/pathless layout routes don't | ||
* interfere. | ||
* | ||
* For example, when moving a route element into an index route and/or a | ||
* pathless layout route, relative link behavior contained within should stay | ||
* the same. Both of the following examples should link back to the root: | ||
* | ||
* <Route path="/"> | ||
* <Route path="accounts" element={<Link to=".."}> | ||
* </Route> | ||
* | ||
* <Route path="/"> | ||
* <Route path="accounts"> | ||
* <Route element={<AccountsLayout />}> // <-- Does not contribute | ||
* <Route index element={<Link to=".."} /> // <-- Does not contribute | ||
* </Route | ||
* </Route> | ||
* </Route> | ||
*/ | ||
export declare function getPathContributingMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[]): T[]; | ||
/** | ||
* @private | ||
*/ | ||
export declare function resolveTo(toArg: To, routePathnames: string[], locationPathname: string, isPathRelative?: boolean): Path; | ||
@@ -289,0 +313,0 @@ /** |
@@ -573,3 +573,3 @@ //////////////////////////////////////////////////////////////////////////////// | ||
if (v5Compat && listener) { | ||
listener({ action, location }); | ||
listener({ action, location: history.location }); | ||
} | ||
@@ -588,3 +588,3 @@ } | ||
if (v5Compat && listener) { | ||
listener({ action, location: location }); | ||
listener({ action, location: history.location }); | ||
} | ||
@@ -591,0 +591,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { convertRoutesToDataRoutes } from "./utils"; | ||
import { convertRoutesToDataRoutes, getPathContributingMatches } from "./utils"; | ||
@@ -82,2 +82,5 @@ export type { | ||
/** @internal */ | ||
export { convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes }; | ||
export { | ||
convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, | ||
getPathContributingMatches as UNSAFE_getPathContributingMatches, | ||
}; |
{ | ||
"name": "@remix-run/router", | ||
"version": "1.0.2", | ||
"version": "1.0.3-pre.0", | ||
"description": "Nested/Data-driven/Framework-agnostic Routing", | ||
@@ -19,2 +19,3 @@ "keywords": [ | ||
"main": "./dist/router.cjs.js", | ||
"unpkg": "./dist/router.umd.min.js", | ||
"module": "./dist/router.js", | ||
@@ -21,0 +22,0 @@ "types": "./dist/index.d.ts", |
55
utils.ts
@@ -332,3 +332,9 @@ import type { Location, Path, To } from "./history"; | ||
for (let i = 0; matches == null && i < branches.length; ++i) { | ||
matches = matchRouteBranch<string, RouteObjectType>(branches[i], pathname); | ||
matches = matchRouteBranch<string, RouteObjectType>( | ||
branches[i], | ||
// incoming pathnames are always encoded from either window.location or | ||
// from route.navigate, but we want to match against the unencoded paths | ||
// in the route definitions | ||
safelyDecodeURI(pathname) | ||
); | ||
} | ||
@@ -706,2 +712,17 @@ | ||
function safelyDecodeURI(value: string) { | ||
try { | ||
return decodeURI(value); | ||
} catch (error) { | ||
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}).` | ||
); | ||
return value; | ||
} | ||
} | ||
function safelyDecodeURIComponent(value: string, paramName: string) { | ||
@@ -842,3 +863,35 @@ try { | ||
* @private | ||
* | ||
* When processing relative navigation we want to ignore ancestor routes that | ||
* do not contribute to the path, such that index/pathless layout routes don't | ||
* interfere. | ||
* | ||
* For example, when moving a route element into an index route and/or a | ||
* pathless layout route, relative link behavior contained within should stay | ||
* the same. Both of the following examples should link back to the root: | ||
* | ||
* <Route path="/"> | ||
* <Route path="accounts" element={<Link to=".."}> | ||
* </Route> | ||
* | ||
* <Route path="/"> | ||
* <Route path="accounts"> | ||
* <Route element={<AccountsLayout />}> // <-- Does not contribute | ||
* <Route index element={<Link to=".."} /> // <-- Does not contribute | ||
* </Route | ||
* </Route> | ||
* </Route> | ||
*/ | ||
export function getPathContributingMatches< | ||
T extends AgnosticRouteMatch = AgnosticRouteMatch | ||
>(matches: T[]) { | ||
return matches.filter( | ||
(match, index) => | ||
index === 0 || (match.route.path && match.route.path.length > 0) | ||
); | ||
} | ||
/** | ||
* @private | ||
*/ | ||
export function resolveTo( | ||
@@ -845,0 +898,0 @@ toArg: To, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1539963
20
14086
2
3