From aa63b5a11c79efa91360aaa6a0395810dd9e5c05 Mon Sep 17 00:00:00 2001 From: Hunter Craft <118154470+hunterckx@users.noreply.github.com> Date: Wed, 11 Dec 2024 22:00:04 -0800 Subject: [PATCH] feat: allow url objects for explore links to have a path before the entity name (#291) (#292) --- .../Link/components/ExploreViewLink/exploreViewLink.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx b/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx index eab2b4bc..d6c99461 100644 --- a/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +++ b/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx @@ -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); } /** @@ -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. @@ -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 + ); } /**