Skip to content

Commit

Permalink
fix: fix inconsistent queryPath accross routes
Browse files Browse the repository at this point in the history
  • Loading branch information
CSharperMantle committed Jul 13, 2023
1 parent e8b42a9 commit d4a97f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/common/__tests__/queryPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ describe("queryPath", () => {
id: 1,
},
] as const
expect(queryPath(null, 1)).toStrictEqual("#")
expect(queryPath(undefined, 1)).toStrictEqual("#")
expect(queryPath([], 1)).toStrictEqual("#")
expect(queryPath(routes, 1)).toStrictEqual("#")
expect(queryPath(null, 1)).toStrictEqual("")
expect(queryPath(undefined, 1)).toStrictEqual("")
expect(queryPath([], 1)).toStrictEqual("")
expect(queryPath(routes, 1)).toStrictEqual("")
})
})
4 changes: 2 additions & 2 deletions src/common/queryPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type TRoutes = readonly TRoute[] | null | undefined

export const queryPath = memoize(
(routes: TRoutes, id: number): string => {
return head(filter(routes, (r) => r?.id === id))?.path ?? "#"
return head(filter(routes, (r) => r?.id === id))?.path ?? ""
},
(_, id) => id
(routes, id) => [routes, id]
)

0 comments on commit d4a97f0

Please sign in to comment.