Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/wouter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,12 @@ export const Link = forwardRef((props, ref) => {
}
});

const targetPathAbsolute =
targetPath[0] === "~" ? targetPath.slice(1) : router.base + targetPath;

// handle nested routers and absolute paths
const href = router.hrefs(
targetPath[0] === "~" ? targetPath.slice(1) : router.base + targetPath,
targetPathAbsolute,
router // pass router as a second argument for convinience
);

Expand All @@ -312,7 +315,9 @@ export const Link = forwardRef((props, ref) => {
onClick,
href,
// `className` can be a function to apply the class if this link is active
className: cls?.call ? cls(currentPath === targetPath) : cls,
className: cls?.call
? cls(router.base + currentPath === targetPathAbsolute)
: cls,
children,
ref,
});
Expand Down