DesktopArticleTarget.init: Fix URI comparison if it contains a port number

If the wiki runs on a host that contains a port number, section edit
links would always reload the page, and the "Add section" tab would
not work.

As it happens, my local testing wiki runs on localhost:3080.

It is an unfortunate naming mishap:
* mw.Uri#host is equivalent to location.hostname
* mw.Uri#getHostPort is equivalent to location.host

In this case, we have to compare the port too, otherwise a setup (my
setup ;) ) where one starts up another wiki on localhost:3081 to test
cross-wiki features would fail.

Change-Id: Ib7de4ba3c3a84888f24186af03bd9dcced131051
This commit is contained in:
Bartosz Dziewoński 2018-07-04 00:09:36 +02:00
parent 92c4e231f2
commit 9ef039dd4b

View file

@ -896,7 +896,7 @@
// Not an edit action
!( 'action' in uri.query || 'veaction' in uri.query ) ||
// Edit target is on another host (e.g. commons file)
uri.host !== location.host ||
uri.getHostPort() !== location.host ||
// Title param doesn't match current page
title && title.getPrefixedText() !== new mw.Title( mw.config.get( 'wgRelevantPageName' ) ).getPrefixedText()
) {