Skip to content

Commit

Permalink
chore: type the parsePath function
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Nov 1, 2021
1 parent 04a01ad commit 82e5352
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/history/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,28 +1043,28 @@ export function createPath({
*
* @see https://github.com/ReactTraining/history/tree/master/docs/api-reference.md#parsepath
*/
export function parsePath(path: string) {
let partialPath: PartialPath = {
export function parsePath(path: string): PartialPath {
let parsedPath: PartialPath = {
search: ''
};

if (path) {
let hashIndex = path.indexOf('#');
if (hashIndex >= 0) {
partialPath.hash = path.substr(hashIndex);
parsedPath.hash = path.substr(hashIndex);
path = path.substr(0, hashIndex);
}

let searchIndex = path.indexOf('?');
if (searchIndex >= 0) {
partialPath.search = path.substr(searchIndex);
parsedPath.search = path.substr(searchIndex);
path = path.substr(0, searchIndex);
}

if (path) {
partialPath.pathname = path;
parsedPath.pathname = path;
}
}

return partialPath;
return parsedPath;
}

0 comments on commit 82e5352

Please sign in to comment.