Skip to content

Commit

Permalink
Fix isCurrent activation on Link
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhirst committed Jul 4, 2022
1 parent 91eb0bf commit e2d08f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const Link: FunctionComponent<LinkProps> = ({
}) => {
const router = useRouter();
const { asPath } = router;
const isCurrent = asPath
.replace("/", "")
.includes(href.toString().replace("/", ""));
const pathTrimmed = asPath.replace("/", "");
const hrefTrimmed = href.toString().replace("/", "");
const isCurrent = hrefTrimmed && pathTrimmed.includes(hrefTrimmed);

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

0 comments on commit e2d08f7

Please sign in to comment.