Skip to content

Commit

Permalink
refactor(nuxt): simplify check in navigateTo for server (#26546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mini-ghost committed Mar 29, 2024
1 parent 9b24363 commit a33674b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/nuxt/src/app/composables/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit a33674b

Please sign in to comment.