mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-13 17:50:37 +00:00
ode-link: Fix link for URLs without protocol
Prepend '//' to relative URLs to turn them to real new (root) addresses instead of relative paths in current domain Bug: T368166 Follow-up: I999937c1f6303ecc64adb6285e73a9ce10f67bd8 Change-Id: I2cf901c7b0454517dc93ea8113dcf69832584c08
This commit is contained in:
parent
0159930cdd
commit
ba35957b9b
|
@ -25,9 +25,14 @@ $( () => {
|
|||
link.classList.add( 'code-link' );
|
||||
|
||||
if ( URLMatch ) {
|
||||
const URL = URLMatch[ 0 ];
|
||||
link.href = URL;
|
||||
linkText = URL;
|
||||
let url = URLMatch[ 0 ];
|
||||
|
||||
if ( !/^https?:/i.test( url ) ) {
|
||||
url = '//' + url;
|
||||
}
|
||||
|
||||
link.href = url;
|
||||
linkText = URLMatch[ 0 ]; // Preserve visual link text as is
|
||||
} else if ( wikilinkMatch ) {
|
||||
linkText = wikilinkMatch[ 0 ];
|
||||
title = mw.Title.newFromText( wikilinkMatch[ 1 ] );
|
||||
|
|
Loading…
Reference in a new issue