@@ -186,8 +186,7 @@ document.addEventListener('DOMContentLoaded', () => {
186186
187187 const isDownloadRequired = ( url , anchorElement , e ) => anchorElement . download || e . metaKey || e . ctrlKey || isDownloadLink ( url ) ;
188188
189- const handleExternalLink = ( e , url ) => {
190- e . preventDefault ( ) ;
189+ const handleExternalLink = ( url ) => {
191190 invoke ( 'plugin:shell|open' , {
192191 path : url ,
193192 } ) ;
@@ -200,24 +199,28 @@ document.addEventListener('DOMContentLoaded', () => {
200199
201200 const detectAnchorElementClick = e => {
202201 const anchorElement = e . target . closest ( 'a' ) ;
202+
203203 if ( anchorElement && anchorElement . href ) {
204- if ( ! anchorElement . target ) {
205- anchorElement . target = '_self' ;
206- }
207204
208205 const hrefUrl = new URL ( anchorElement . href ) ;
209206 const absoluteUrl = hrefUrl . href ;
210207 let filename = anchorElement . download || getFilenameFromUrl ( absoluteUrl ) ;
211208
212209 // Handling external link redirection, _blank will automatically open.
213210 if ( isExternalLink ( absoluteUrl ) && ( [ '_new' ] . includes ( anchorElement . target ) ) ) {
214- handleExternalLink ( e , absoluteUrl ) ;
211+ handleExternalLink ( absoluteUrl ) ;
215212 return ;
216213 }
217214
218215 // Process download links for Rust to handle.
219216 if ( isDownloadRequired ( absoluteUrl , anchorElement , e ) && ! externalDownLoadLink ( ) && ! isSpecialDownload ( absoluteUrl ) ) {
220217 handleDownloadLink ( e , absoluteUrl , filename ) ;
218+ return ;
219+ }
220+
221+ // App internal jump.
222+ if ( ! anchorElement . target ) {
223+ location . href = anchorElement . href ;
221224 }
222225 }
223226 } ;
@@ -239,7 +242,7 @@ document.addEventListener('DOMContentLoaded', () => {
239242 } else {
240243 const baseUrl = window . location . origin + window . location . pathname ;
241244 const hrefUrl = new URL ( url , baseUrl ) ;
242- handleExternalLink ( e , hrefUrl . href ) ;
245+ handleExternalLink ( hrefUrl . href ) ;
243246 }
244247 // Call the original window.open function to maintain its normal functionality.
245248 return originalWindowOpen . call ( window , url , name , specs ) ;
0 commit comments