Skip to content

Commit e026838

Browse files
committed
remove parseLocation
1 parent a552625 commit e026838

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

packages/react-router-dom/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
generatePath,
1717
matchRoutes,
1818
matchPath,
19-
parseLocation,
2019
resolvePath,
2120
renderMatches,
2221
useHref,
@@ -65,7 +64,6 @@ export {
6564
generatePath,
6665
matchRoutes,
6766
matchPath,
68-
parseLocation,
6967
renderMatches,
7068
resolvePath,
7169
useHref,

packages/react-router-native/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
generatePath,
2020
matchRoutes,
2121
matchPath,
22-
parseLocation,
2322
resolvePath,
2423
renderMatches,
2524
useHref,
@@ -53,7 +52,6 @@ export {
5352
generatePath,
5453
matchRoutes,
5554
matchPath,
56-
parseLocation,
5755
resolvePath,
5856
renderMatches,
5957
useHref,

packages/react-router/index.tsx

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ export function Router({
277277
locationProp = parsePath(locationProp);
278278
}
279279

280-
let { pathname, search, hash, state, key } = parseLocation(locationProp);
280+
let {
281+
pathname = "/",
282+
search = "",
283+
hash = "",
284+
state = null,
285+
key = "default"
286+
} = locationProp;
281287

282288
let location = React.useMemo(() => {
283289
let trailingPathname = stripBasename(pathname, basename);
@@ -447,23 +453,6 @@ type ParamParseKey<Segment extends string> =
447453
/**
448454
* Returns a complete Location with an absolute pathname
449455
*/
450-
export function parseLocation({
451-
pathname = "/",
452-
...rest
453-
}: Partial<Location>): Location {
454-
const defaultLocation = {
455-
pathname: "/",
456-
search: "",
457-
hash: "",
458-
state: null,
459-
key: "default"
460-
};
461-
return {
462-
...defaultLocation,
463-
...rest,
464-
pathname: normalizePathnameStart(pathname)
465-
};
466-
}
467456

468457
/**
469458
* Returns the current navigation action which describes how the router came to
@@ -862,11 +851,10 @@ export function matchRoutes(
862851
locationArg: Partial<Location> | string,
863852
basename = "/"
864853
): RouteMatch[] | null {
865-
let absolutePathname = parseLocation(
866-
typeof locationArg === "string" ? parsePath(locationArg) : locationArg
867-
).pathname;
854+
let location =
855+
typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
868856

869-
let pathname = stripBasename(absolutePathname, basename);
857+
let pathname = stripBasename(location.pathname || "/", basename);
870858

871859
if (pathname == null) {
872860
return null;

0 commit comments

Comments
 (0)