Steps to replicate the issue (include links if applicable):
This is regarding the JavaScript variable, mw.config.get('wgServer') which is used in user scripts. When running scripts on en.m.wikipedia.org (e.g., when a user script is running on a mobile phone), mw.config.get('wgServer') is "//en.wikipedia.org" rather than the expected "//en.m.wikipedia.org".
Here's an example from the console:
> location
< Location {href: "https://en.m.wikipedia.org/wiki/Main_Page", protocol: "https:", host: "en.m.wikipedia.org", hostname: "en.m.wikipedia.org", port: "", …}
> mw.config.get('wgServer');
< "//en.wikipedia.org"What happens?:
I was using wgServer as part of comparing hrefs (on a Wikipedia page) in a user script to make sure I only match local pages. The code didn't work on mobile because lots of page links looked like links to elsewhere.
What I'm doing as a workaround for now is using window.location.origin because I want this code to work on both desktop and mobile.
What should have happened instead?:
It seems like wgServer should just be the current server. If there's a reason it needs to be the non-mobile site then perhaps there should be another variable that tells you the name of the current site, the one expected to be the destination for most links.
Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
Current English Wikipedia.
Other information (browser name/version, screenshots, etc.):
Tested on Safari.