Skip to content

Commit d298c41

Browse files
frontend: App: Force external links to open in new tab
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent b64f29f commit d298c41

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

core/frontend/src/App.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,21 @@ export default Vue.extend({
801801
if (target.offsetParent !== this.$refs.contextMenu) {
802802
this.context_menu_visible = false
803803
}
804+
805+
// Force all external links to open in a new tab
806+
const anchor = target.closest('a')
807+
if (!anchor || anchor.target === '_blank') return
808+
const href = anchor.getAttribute('href')
809+
if (!href) return
810+
try {
811+
const url = new URL(href, window.location.origin)
812+
if (url.origin !== window.location.origin) {
813+
event.preventDefault()
814+
window.open(href, '_blank', 'noopener,noreferrer')
815+
}
816+
} catch {
817+
// Invalid URL, ignore
818+
}
804819
})
805820
this.bootstrap_version = await VCU.loadBootstrapCurrentVersion()
806821
},

0 commit comments

Comments
 (0)