Skip to content

Commit

Permalink
feat: allow url objects for explore links to have a path before the e…
Browse files Browse the repository at this point in the history
…ntity name (#291) (#292)
  • Loading branch information
hunterckx authored Dec 12, 2024
1 parent 5029b20 commit aa63b5a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const ExploreViewLink = ({
* @returns entity list type.
*/
function getEntityListType(href: UrlObjectWithHrefAndQuery["href"]): string {
return href.substring(1);
return href.substring(href.lastIndexOf("/") + 1);
}

/**
Expand Down Expand Up @@ -139,7 +139,7 @@ function isValidExploreURL(
}

/**
* Returns true if the given href is a configured key in the explore state's entityPageState.
* Returns true if the given href is a path ending with a configured key in the explore state's entityPageState.
* @param url - Explore link URL.
* @param exploreState - Explore state.
* @returns true if the given href is configured in the explore state.
Expand All @@ -150,7 +150,10 @@ function isValidHref(
): boolean {
const { entityPageState } = exploreState;
const { href } = url;
return href.startsWith("/") && href.substring(1) in entityPageState;
return (
href.startsWith("/") &&
href.substring(href.lastIndexOf("/") + 1) in entityPageState
);
}

/**
Expand Down

0 comments on commit aa63b5a

Please sign in to comment.