fix: only checking last part of filter on destination pages to create basePathWithoutFilters
Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user