Skip to content

Commit

Permalink
Fix edge case on previous
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhirst committed Jul 4, 2022
1 parent e2d08f7 commit dece3f7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const Link: FunctionComponent<LinkProps> = ({
const { asPath } = router;
const pathTrimmed = asPath.replace("/", "");
const hrefTrimmed = href.toString().replace("/", "");
const isCurrent = hrefTrimmed && pathTrimmed.includes(hrefTrimmed);
const isCurrent =
asPath === "/"
? asPath === href
: hrefTrimmed && pathTrimmed.includes(hrefTrimmed);

const classes = classNames(className, {
[currentClassName]: isCurrent,
Expand Down

0 comments on commit dece3f7

Please sign in to comment.