Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
fix(useBackLink): Fix inverted subpath logic, #164
Browse files Browse the repository at this point in the history
  • Loading branch information
diondiondion committed Nov 5, 2021
1 parent 9ceda61 commit 41648a8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/useBackLink/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ function useBackLink(options: BackLinkOptions = {}): Location | null {
}

function getShouldSkipLocation(location) {
const ignoreSubpath = basePath?.startsWith(
stripSlashFromEnd(getLocationPathname(location))
);
const formattedLocation = basePath
? stripSlashFromEnd(getLocationPathname(location))
: null;

const ignoreSubpath = formattedLocation?.startsWith(basePath);

const skipLocation = shouldSkipLocation?.(location);

Expand All @@ -42,6 +44,8 @@ function useBackLink(options: BackLinkOptions = {}): Location | null {

const backLink = getBackLink();

console.log(basePath, historyStack);

return backLink || fallback;
}

Expand Down

0 comments on commit 41648a8

Please sign in to comment.