File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -47,11 +47,7 @@ const MarkdownConverter = class extends LitElement {
4747 // 4. Wrap any remaining http(s) URLs
4848 const linked = noLinks . replace (
4949 / ( h t t p s ? : \/ \/ [ ^ \s < ] + [ ^ < . , : ; " ' ) \] \s ] ) / g,
50- ( url ) => {
51- // Ensure the destination URL has https:// at the beginning
52- const href = url . startsWith ( 'http' ) ? url : `https://${ url } ` ;
53- return `[${ url } ](${ href } )` ;
54- } ,
50+ ( url ) => `[${ url } ](${ url } )` ,
5551 ) ;
5652
5753 // 5. Restore links/images, inline code, then fenced code
@@ -103,6 +99,10 @@ const MarkdownConverter = class extends LitElement {
10399 this . querySelectorAll ( 'a:not([target="_blank"])' ) . forEach ( ( link ) => {
104100 link . setAttribute ( 'target' , '_blank' ) ;
105101 link . setAttribute ( 'rel' , 'noreferrer noopener' ) ;
102+ const href = link . getAttribute ( 'href' ) || '' ;
103+ if ( ! href . startsWith ( 'http' ) ) {
104+ link . setAttribute ( 'href' , `https://${ href } ` ) ;
105+ }
106106 link . innerHTML += ' <span class="sr-only top-0 -left-[1000px]">(opens in new tab)</span>' ;
107107 } ) ;
108108 }
You can’t perform that action at this time.
0 commit comments