From dbd692b5ed7f4bc9c28ecf3f9c1e5f8a74049419 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 9 Apr 2019 14:43:24 +0100 Subject: [PATCH] InternalLink: Add special case for fragment with no title Bug: T218581 Change-Id: I11e2de90e582d184a3f8cdd65dfc0858571aa397 --- .../ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js index 707cc42e1e..fb724dd514 100644 --- a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js +++ b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js @@ -173,6 +173,12 @@ ve.dm.MWInternalLinkAnnotation.static.getHref = function ( dataElement ) { } } ).join( '' ); } + if ( encodedTitle.slice( 0, 1 ) === '#' ) { + // Special case: For a newly created link to a #fragment with + // no explicit title use the current title as prefix (T218581) + // TODO: Pass a 'doc' param to getPageName + encodedTitle = ve.init.target.getPageName() + encodedTitle; + } return './' + encodedTitle; };