refactor(nuxt): simplify check in `navigateTo` for server (#26546)

This commit is contained in:
Alex Liu 2024-03-29 18:42:06 +08:00 committed by GitHub
parent 9b243631b4
commit a33674b06b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 10 deletions

View File

@ -125,18 +125,16 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na
const toPath = typeof to === 'string' ? to : (withQuery((to as RouteLocationPathRaw).path || '/', to.query || {}) + (to.hash || ''))
// Early open handler
if (options?.open) {
if (import.meta.client) {
const { target = '_blank', windowFeatures = {} } = options.open
if (import.meta.client && options?.open) {
const { target = '_blank', windowFeatures = {} } = options.open
const features = Object.entries(windowFeatures)
.filter(([_, value]) => value !== undefined)
.map(([feature, value]) => `${feature.toLowerCase()}=${value}`)
.join(', ')
const features = Object.entries(windowFeatures)
.filter(([_, value]) => value !== undefined)
.map(([feature, value]) => `${feature.toLowerCase()}=${value}`)
.join(', ')
open(toPath, target, features)
return Promise.resolve()
}
open(toPath, target, features)
return Promise.resolve()
}
const isExternal = options?.external || hasProtocol(toPath, { acceptRelative: true })