diff --git a/Popups.hooks.php b/Popups.hooks.php index 669922d06..5880f34a8 100644 --- a/Popups.hooks.php +++ b/Popups.hooks.php @@ -53,6 +53,7 @@ class PopupsHooks { $moduleDependencies = array( 'mediawiki.api', 'mediawiki.jqueryMsg', + 'mediawiki.Uri', 'moment', 'jquery.jStorage', 'jquery.client', diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index fbb5b6bcf..dbb454f2d 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -154,7 +154,12 @@ return mw.popups.$content .find( 'a[href][title]:not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')' ) .filter( function () { - return ( this.href.replace(/^https?:\/\//,'//') === ( mw.config.get( 'wgServer' ) + mw.util.getUrl( this.title ) ).replace(/^https?:\/\//,'//') ); + var linkHref = new mw.Uri( this.href ), + expectedHref = new mw.Uri( mw.util.getUrl( this.title ) ); + + // don't compare fragment to display popups on anchored page links + linkHref.fragment = undefined; + return linkHref.toString() === expectedHref.toString(); } ); };