fix(kit): ensure getNuxtVersion returns string (#28125)

This commit is contained in:
Bobbie Goede 2024-07-12 14:14:39 +02:00 committed by GitHub
parent f8963f1dfe
commit 694229071b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,8 +108,8 @@ export function isNuxt3 (nuxt: Nuxt = useNuxt()) {
*/ */
export function getNuxtVersion (nuxt: Nuxt | any = useNuxt() /* TODO: LegacyNuxt */) { export function getNuxtVersion (nuxt: Nuxt | any = useNuxt() /* TODO: LegacyNuxt */) {
const rawVersion = nuxt?._version || nuxt?.version || nuxt?.constructor?.version const rawVersion = nuxt?._version || nuxt?.version || nuxt?.constructor?.version
if (!rawVersion) { if (typeof rawVersion !== 'string') {
throw new Error('Cannot determine nuxt version! Is current instance passed?') throw new TypeError('Cannot determine nuxt version! Is current instance passed?')
} }
return rawVersion.replace(/^v/g, '') return rawVersion.replace(/^v/g, '')
} }