File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff 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 },
You can’t perform that action at this time.
0 commit comments