Skip to content

Commit

Permalink
parsePathInput for nonstring inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
thejohnhoffer committed Dec 20, 2021
1 parent 2bf3314 commit 657fc44
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/history/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,13 @@ export function createHashHistory(
return parsePath(pathname.replace(hashRoot, '/'));
}

function parsePathOutput(pathname) {
return parsePath(pathname.replace('/', hashRoot));
function parsePathOutput(to) {
let path = typeof to === 'string' ? parsePath(to) : to
let pathname = parsePath(pathname.replace('/', hashRoot));
return {
...path,
pathname
}
}

function getIndexAndLocation(): [number, Location] {
Expand Down Expand Up @@ -708,7 +713,7 @@ export function createHashHistory(
pathname: location.pathname,
hash: '',
search: '',
...(typeof to === 'string' ? parsePathOutput(to) : to),
...parsePathOutput(to),
state,
key: createKey()
});
Expand Down

0 comments on commit 657fc44

Please sign in to comment.