Fix: Interceptor debe revisar target antes de parsear URL
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 56s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 56s
- Mover verificaci\u00f3n de target='_blank' antes del parseo de URL - Esto garantiza que links con target='_blank' nunca sean interceptados - Permite que desktop abra PWAs en nuevas ventanas correctamente
This commit is contained in:
@@ -30,19 +30,19 @@ export default defineNuxtPlugin(() => {
|
||||
const href = link.getAttribute('href')
|
||||
if (!href) return
|
||||
|
||||
// Si el enlace tiene target="_blank", NUNCA interceptar
|
||||
// Esto permite que en desktop los enlaces abran nuevas ventanas (PWAs)
|
||||
const linkTarget = link.getAttribute('target')
|
||||
if (linkTarget === '_blank') {
|
||||
console.debug('Permitiendo apertura de nueva ventana para:', href)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(href, window.location.origin)
|
||||
|
||||
// Solo interceptar enlaces que apunten a este origin
|
||||
if (url.origin === appOrigin) {
|
||||
// Si el enlace tiene target="_blank", no interceptar
|
||||
// Esto permite que en desktop los enlaces abran nuevas ventanas (PWAs)
|
||||
const linkTarget = link.getAttribute('target')
|
||||
if (linkTarget === '_blank') {
|
||||
console.debug('Permitiendo apertura de nueva ventana para:', href)
|
||||
return
|
||||
}
|
||||
|
||||
// Prevenir comportamiento por defecto
|
||||
event.preventDefault()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user