fix(SW-2119): Fixed issue where we were redirecting to the parent instead of not found
Approved-by: Matilda Landström
This commit is contained in:
@@ -40,22 +40,21 @@ export const middleware: NextMiddleware = async (request) => {
|
|||||||
await getUidAndContentTypeByPath(incomingPathNameParts.join("/"))
|
await getUidAndContentTypeByPath(incomingPathNameParts.join("/"))
|
||||||
|
|
||||||
if (parentUid) {
|
if (parentUid) {
|
||||||
contentType = parentContentType
|
|
||||||
uid = parentUid
|
|
||||||
switch (parentContentType) {
|
switch (parentContentType) {
|
||||||
// If the parent is the startpage, we should not be able to resolve a subpage.
|
|
||||||
case PageContentTypeEnum.startPage:
|
|
||||||
throw notFound(
|
|
||||||
`Unable to resolve CMS entry for page "${pathWithoutTrailingSlash}"`
|
|
||||||
)
|
|
||||||
case PageContentTypeEnum.hotelPage:
|
case PageContentTypeEnum.hotelPage:
|
||||||
// E.g. Dedicated pages for restaurant, parking etc.
|
// E.g. Dedicated pages for restaurant, parking etc.
|
||||||
searchParams.set("subpage", subpage)
|
searchParams.set("subpage", subpage)
|
||||||
|
contentType = parentContentType
|
||||||
|
uid = parentUid
|
||||||
break
|
break
|
||||||
case PageContentTypeEnum.destinationCityPage:
|
case PageContentTypeEnum.destinationCityPage:
|
||||||
case PageContentTypeEnum.destinationCountryPage:
|
case PageContentTypeEnum.destinationCountryPage:
|
||||||
// E.g. Active filters inside destination pages to filter hotels.
|
// E.g. Active filters inside destination pages to filter hotels.
|
||||||
searchParams.set("filterFromUrl", subpage)
|
searchParams.set("filterFromUrl", subpage)
|
||||||
|
contentType = parentContentType
|
||||||
|
uid = parentUid
|
||||||
|
break
|
||||||
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user