mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Fix logic in link input widget
Previously pageExists thought matchingPages was an indexed object when in fact it was an array. This didn't manifest as a bug as we subsequently check the normalised URL in the correct manner (using indexOf), but it did remove the optimisation of not running mw.Title if there was an exact match. Change-Id: Ic616cbfa0d7ed5447e032dd1f772779db2dc19e5
This commit is contained in:
parent
1ea9016cf8
commit
51be472159
|
@ -96,7 +96,11 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupMenuItemsFromData = function (
|
|||
menu$$ = this.lookupMenu.$$,
|
||||
items = [],
|
||||
matchingPages = data,
|
||||
pageExists = this.value in matchingPages;
|
||||
// If not found, run value through mw.Title to avoid treating a match as a
|
||||
// mismatch where normalisation would make them matching (bug 48476)
|
||||
pageExists =
|
||||
ve.indexOf( this.value, matchingPages ) !== -1 ||
|
||||
ve.indexOf( new mw.Title( this.value ).getPrefixedText(), matchingPages ) !== -1;
|
||||
|
||||
// External link
|
||||
if ( ve.init.platform.getExternalLinkUrlProtocolsRegExp().test( this.value ) ) {
|
||||
|
@ -111,15 +115,7 @@ ve.ui.MWLinkTargetInputWidget.prototype.getLookupMenuItemsFromData = function (
|
|||
}
|
||||
|
||||
// Internal link
|
||||
if (
|
||||
!pageExists &&
|
||||
(
|
||||
!matchingPages ||
|
||||
// Run value through mw.Title to avoid treating a match as a mismatch where
|
||||
// normalisation would make them matching (bug 48476)
|
||||
matchingPages.indexOf( new mw.Title( this.value ).getPrefixedText() ) === -1
|
||||
)
|
||||
) {
|
||||
if ( !pageExists ) {
|
||||
items.push( new ve.ui.MenuSectionItemWidget(
|
||||
'newPage',
|
||||
{ '$$': menu$$, 'label': ve.msg( 'visualeditor-linkinspector-suggest-new-page' ) }
|
||||
|
|
Loading…
Reference in a new issue