Old-slug redirects skip never-published drafts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
67e9655376
commit
4c199acdfd
@@ -34,7 +34,7 @@ type ResolveRedirectArgs = {
|
||||
segments: string[] | undefined
|
||||
}
|
||||
|
||||
type DocShape = { slug?: unknown }
|
||||
type DocShape = { _status?: unknown; slug?: unknown }
|
||||
|
||||
/**
|
||||
* Resolves a 301/308 destination for a URL that no longer matches any current
|
||||
@@ -90,6 +90,10 @@ export async function resolveRedirect({
|
||||
where: { [`${historyField}.slug`]: { equals: oldSlug } } as never,
|
||||
})
|
||||
const doc = (res?.docs?.[0] ?? null) as DocShape | null
|
||||
// A never-published draft must not be reachable — nor its new slug
|
||||
// revealed — through a redirect (same rule as resolveRoute).
|
||||
const status = doc?._status
|
||||
if (doc && status !== undefined && status !== null && status !== 'published') {continue}
|
||||
if (doc && typeof doc[slugField as keyof DocShape] === 'string') {
|
||||
currentSlug = doc[slugField as keyof DocShape] as string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user