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,12 +30,7 @@ export default defineNuxtPlugin(() => {
|
|||||||
const href = link.getAttribute('href')
|
const href = link.getAttribute('href')
|
||||||
if (!href) return
|
if (!href) return
|
||||||
|
|
||||||
try {
|
// Si el enlace tiene target="_blank", NUNCA interceptar
|
||||||
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)
|
// Esto permite que en desktop los enlaces abran nuevas ventanas (PWAs)
|
||||||
const linkTarget = link.getAttribute('target')
|
const linkTarget = link.getAttribute('target')
|
||||||
if (linkTarget === '_blank') {
|
if (linkTarget === '_blank') {
|
||||||
@@ -43,6 +38,11 @@ export default defineNuxtPlugin(() => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = new URL(href, window.location.origin)
|
||||||
|
|
||||||
|
// Solo interceptar enlaces que apunten a este origin
|
||||||
|
if (url.origin === appOrigin) {
|
||||||
// Prevenir comportamiento por defecto
|
// Prevenir comportamiento por defecto
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user