fix: only checking last part of filter on destination pages to create basePathWithoutFilters

Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
Erik Tiekstra
2025-07-17 13:07:37 +00:00
parent f2716c8b5e
commit 876a9cab7f

View File

@@ -71,9 +71,16 @@ export function getBasePathNameWithoutFilters(
pathname: string, pathname: string,
filterSlugs: string[] filterSlugs: string[]
) { ) {
const pathSegments = pathname.split("/") if (!filterSlugs.length) {
const filteredSegments = pathSegments.filter( return pathname
(segment) => !filterSlugs.includes(segment) }
)
return filteredSegments.join("/") const lastSlashIndex = pathname.lastIndexOf("/")
const lastSegment = pathname.slice(lastSlashIndex + 1)
if (filterSlugs.includes(lastSegment)) {
return pathname.slice(0, lastSlashIndex) || "/"
}
return pathname
} }