Last modified: 2012-12-31 17:15:14 UTC
The following links generates all a difference between revisions: https://www.mediawiki.org/wiki/?diff https://www.mediawiki.org/wiki/?diff= https://www.mediawiki.org/wiki/?diff=0 https://www.mediawiki.org/wiki/?dif%66=0 The JavaScript function mw.util.getParamValue( 'diff' ) generates: mw.util.getParamValue( 'diff', '?diff' ) // null mw.util.getParamValue( 'diff', '?diff=' ) // "" mw.util.getParamValue( 'diff', '?diff=0' ) // 0 mw.util.getParamValue( 'diff', '?dif%66=0' ) // null The suggested usage in https://www.mediawiki.org/wiki/ResourceLoader/Default_modules#getParamValue mw.util.getParamValue( 'diff' ) !== null isn't suitable to distinguish between difference and normal view. It should be possible in JavaScript to get the same result as in PHP. A possible solution would be to transfer a normalized URL as string or object in a wiki global with the content.
This is a similar problem as in Bug 31918.
getParamValue() should decodeURIComponent() the keys like the values in the query string. Expected results: mw.util.getParamValue( '%', '?%25=p' ) // "p" mw.util.getParamValue( 'p', '?p=%25' ) // "%"
(In reply to comment #0) > mw.util.getParamValue( 'diff', '?diff' ) // null > mw.util.getParamValue( 'diff', '?diff=' ) // "" > mw.util.getParamValue( 'diff', '?diff=0' ) // 0 > mw.util.getParamValue( 'diff', '?dif%66=0' ) // null These are all returning as expected imho. One should never use special characters in keys (and no core or extension code does so). If you need processed values for server-side values, then these should be exposed by the server explicitly to avoid repeating logic. Because some actions or special pages submit (or at least support) them from POST, in which case getParamValue wouldn't get it. Point being that accessing the url directly for these kind of things is unreliable and incorrect (more duck-punching or repeating internal details than an API. The url is an input method for the wiki, among other input methods. It it not an output method for what the wiki is doing). So in this case there could be something like mw.action.fields which would contain whatever data the current action is using / exposing (be it GET parameters, POST parameters or other related information to the current action). The latter is further described in Bug 31918.