fix(opener): doesn't open same origin links (#3018)

This commit is contained in:
Tony
2025-10-04 21:16:08 +08:00
committed by GitHub
parent e25a9339f4
commit 67a7bf80f8
3 changed files with 8 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"opener": patch
"opener-js": patch
---
Fix opener doesn't open same origin links in the browser
+1 -3
View File
@@ -46,10 +46,8 @@ window.addEventListener('click', function (evt) {
// return early if
if (
// same origin (internal navigation)
url.origin === window.location.origin
// not default protocols
|| ['http:', 'https:', 'mailto:', 'tel:'].every((p) => url.protocol !== p)
['http:', 'https:', 'mailto:', 'tel:'].every((p) => url.protocol !== p)
)
return
+1 -1
View File
@@ -1 +1 @@
!function(){"use strict";"function"==typeof SuppressedError&&SuppressedError,window.addEventListener("click",(function(e){if(e.defaultPrevented||0!==e.button||e.metaKey||e.altKey)return;const t=e.composedPath().find((e=>e instanceof Node&&"A"===e.nodeName.toUpperCase()));if(!t||!t.href||"_blank"!==t.target&&!e.ctrlKey&&!e.shiftKey)return;const n=new URL(t.href);n.origin===window.location.origin||["http:","https:","mailto:","tel:"].every((e=>n.protocol!==e))||(e.preventDefault(),async function(e,t={},n){window.__TAURI_INTERNALS__.invoke(e,t,n)}("plugin:opener|open_url",{url:n}))}))}();
!function(){"use strict";"function"==typeof SuppressedError&&SuppressedError,window.addEventListener("click",(function(e){if(e.defaultPrevented||0!==e.button||e.metaKey||e.altKey)return;const t=e.composedPath().find((e=>e instanceof Node&&"A"===e.nodeName.toUpperCase()));if(!t||!t.href||"_blank"!==t.target&&!e.ctrlKey&&!e.shiftKey)return;const n=new URL(t.href);["http:","https:","mailto:","tel:"].every((e=>n.protocol!==e))||(e.preventDefault(),async function(e,t={},n){window.__TAURI_INTERNALS__.invoke(e,t,n)}("plugin:opener|open_url",{url:n}))}))}();