diff --git a/modules/ve-mw/preinit/ve.utils.parsoid.js b/modules/ve-mw/preinit/ve.utils.parsoid.js index 892dc354f4..55fbd6e24d 100644 --- a/modules/ve-mw/preinit/ve.utils.parsoid.js +++ b/modules/ve-mw/preinit/ve.utils.parsoid.js @@ -261,12 +261,12 @@ mw.libs.ve.fixFragmentLinks = function ( container, docTitle, prefix ) { * Parse URL to get title it points to. * * @param {string} href - * @param {HTMLDocument|string} doc Document whose base URL to use, or base URL as a string. + * @param {HTMLDocument} doc Document whose base URL to use * @return {Object} Information about the given href - * @return {string} return.title - * The title of the internal link, else the original href if href is external - * @return {string} return.rawTitle - * The title without URL decoding and underscore normalization applied + * @return {string} [return.title] + * The title of the internal link (if the href is internal) + * @return {string} [return.rawTitle] + * The title without URL decoding and underscore normalization applied (if the href is internal) * @return {boolean} return.isInternal * True if the href pointed to the local wiki, false if href is external */ @@ -342,10 +342,14 @@ mw.libs.ve.getTargetDataFromHref = function ( href, doc ) { } } + if ( !isInternal ) { + return { isInternal: false }; + } + // This href doesn't necessarily come from Parsoid (and it might not have the "./" prefix), but // this method will work fine. var data = mw.libs.ve.parseParsoidResourceName( href ); - data.isInternal = isInternal; + data.isInternal = true; return data; }; diff --git a/modules/ve-mw/tests/preinit/ve.utils.parsoid.test.js b/modules/ve-mw/tests/preinit/ve.utils.parsoid.test.js index 0d170a6e82..86bcb9affe 100644 --- a/modules/ve-mw/tests/preinit/ve.utils.parsoid.test.js +++ b/modules/ve-mw/tests/preinit/ve.utils.parsoid.test.js @@ -109,8 +109,6 @@ QUnit.test( 'getTargetDataFromHref', ( assert ) => { msg: 'Valid protocol is handled as external link', href: 'https://example.net/', expectedInfo: { - title: 'https://example.net/', - rawTitle: 'https://example.net/', isInternal: false } }, @@ -118,8 +116,6 @@ QUnit.test( 'getTargetDataFromHref', ( assert ) => { msg: 'Valid protocol is handled as external link', href: 'mailto:example@example.net', expectedInfo: { - title: 'mailto:example@example.net', - rawTitle: 'mailto:example@example.net', isInternal: false } }