jenkins-bot has submitted this change and it was merged. Change subject: Fix getLocationAgnosticMwApi behavior in Internet Explorer ......................................................................
Fix getLocationAgnosticMwApi behavior in Internet Explorer * The apiEndpoint gets initialized as: "https://www.wikidata.org/w/api.php". That's expected. The "s" should be mentioned explicitely. * The local counterpart is initialized as: "//www.wikidata.org/w/api.php". That's also expected and not wrong. What happens is that IE returns "www.wikidata.org:443" for the first but "www.wikidata.org" for the second. This is not the same (but should). Bug: T136543 Change-Id: I329768d5c309f56b5eaadffd03339f2c0b03f21d (cherry picked from commit d239f7497676c0d73958a727182444fb8adca312) --- M src/getLocationAgnosticMwApi.js 1 file changed, 6 insertions(+), 5 deletions(-) Approvals: JanZerebecki: Looks good to me, approved jenkins-bot: Verified diff --git a/src/getLocationAgnosticMwApi.js b/src/getLocationAgnosticMwApi.js index 90c5c61..24c8fa6 100644 --- a/src/getLocationAgnosticMwApi.js +++ b/src/getLocationAgnosticMwApi.js @@ -8,6 +8,11 @@ * @return {string} */ function getHost( url ) { + // Internet Explorer returns an incomplete host (without port) when the protocol is missing. + if ( /^\/\//.test( url ) ) { + url = location.protocol + url; + } + var parser = document.createElement( 'A' ); parser.href = url; return parser.host; @@ -26,11 +31,7 @@ * @return {mediaWiki.Api} */ wb.api.getLocationAgnosticMwApi = function( apiEndpoint ) { - var localApiEndpoint = mw.config.get( 'wgServer' ) - + mw.config.get( 'wgScriptPath' ) - + '/api.php'; - - if ( getHost( localApiEndpoint ) !== getHost( apiEndpoint ) ) { + if ( getHost( apiEndpoint ) !== getHost( mw.config.get( 'wgServer' ) ) ) { // Use mw.ForeignApi if the api we want to use is on a different domain. return new mw.ForeignApi( apiEndpoint ); } -- To view, visit https://gerrit.wikimedia.org/r/291769 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I329768d5c309f56b5eaadffd03339f2c0b03f21d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseJavaScriptApi Gerrit-Branch: 1.1.x Gerrit-Owner: JanZerebecki <[email protected]> Gerrit-Reviewer: JanZerebecki <[email protected]> Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
