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

This commit is contained in:
Bobbie Goede 2024-07-12 14:14:39 +02:00 committed by Daniel Roe
parent 057cfa99bf
commit e102d1d444
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

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