The danger of using || here is apparent if you consider the
following case:
mw.util.getParamValue( 'action', document.referrer );
If document.referrer is the empty string (as it often is),
getParamValue will look up the 'action' parameter in the
current URL, which is surely unintended. The solution is to
use the default value if and only if the url parameter is
undefined.
Change-Id: Ifd949f890d2f974dacc40e549c820c434ce57f53
* @return mixed Parameter value or null.
*/
getParamValue: function ( param, url ) {
- url = url || document.location.href;
+ if ( url === undefined ) {
+ url = document.location.href;
+ }
// Get last match, stop at hash
var re = new RegExp( '^[^#]*[&?]' + $.escapeRE( param ) + '=([^&#]*)' ),
m = re.exec( url );