fix(nuxt): remove trailing slash before checking if prerendered (#24516)

This commit is contained in:
Daniel Roe 2023-11-29 11:18:24 +01:00 committed by GitHub
parent 1b1cc4f4e9
commit 5b4d638720
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { hasProtocol, joinURL } from 'ufo'
import { hasProtocol, joinURL, withoutTrailingSlash } from 'ufo'
import { parse } from 'devalue'
import { useHead } from '@unhead/vue'
import { getCurrentInstance } from 'vue'
@ -79,6 +79,7 @@ async function _importPayload (payloadURL: string) {
export async function isPrerendered (url = useRoute().path) {
// Note: Alternative for server is checking x-nitro-prerender header
if (!appManifest) { return !!useNuxtApp().payload.prerenderedAt }
url = withoutTrailingSlash(url)
const manifest = await getAppManifest()
if (manifest.prerendered.includes(url)) {
return true