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,
|
||||
filterSlugs: string[]
|
||||
) {
|
||||
const pathSegments = pathname.split("/")
|
||||
const filteredSegments = pathSegments.filter(
|
||||
(segment) => !filterSlugs.includes(segment)
|
||||
)
|
||||
return filteredSegments.join("/")
|
||||
if (!filterSlugs.length) {
|
||||
return pathname
|
||||
}
|
||||
|
||||
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