diff --git a/.changes/opener-same-origin-link.md b/.changes/opener-same-origin-link.md new file mode 100644 index 0000000000..5bed71c4a5 --- /dev/null +++ b/.changes/opener-same-origin-link.md @@ -0,0 +1,6 @@ +--- +"opener": patch +"opener-js": patch +--- + +Fix opener doesn't open same origin links in the browser diff --git a/plugins/opener/guest-js/init.ts b/plugins/opener/guest-js/init.ts index 6f81141a2b..4c2b631fbf 100644 --- a/plugins/opener/guest-js/init.ts +++ b/plugins/opener/guest-js/init.ts @@ -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 diff --git a/plugins/opener/src/init-iife.js b/plugins/opener/src/init-iife.js index 51f6f0684c..3a9f95b7ef 100644 --- a/plugins/opener/src/init-iife.js +++ b/plugins/opener/src/init-iife.js @@ -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}))}))}();