Skip to content

Commit f35cc69

Browse files
committed
add normalizeUrl
1 parent 7c57728 commit f35cc69

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

router/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ export function useRouteState<T extends {}>(key: string, initial: T) {
102102

103103
export const RouterHost = ({
104104
children,
105+
normalizeUrl = (url: string) => url,
105106
Shell,
106107
onRouteUpdated,
107108
}: {
108109
children: React.ReactElement;
110+
normalizeUrl?: (url: string) => string;
109111
Shell: React.ComponentType<{ children: React.ReactElement; route?: string }>;
110112
onRouteUpdated?: (path: string) => void;
111113
}) => {
112114
const pathname = useLocationProperty(
113-
() => location.pathname + location.search,
115+
() => normalizeUrl(location.pathname + location.search),
114116
() => globalX.__INITIAL_ROUTE__
115117
);
116118
const [current, setCurrent] = useState(children);

0 commit comments

Comments
 (0)