r89914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89913‎ | r89914 | r89915 >
Date:05:15, 12 June 2011
Author:neilk
Status:ok (Comments)
Tags:
Comment:
fix for missing param values, linting
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.Uri.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.Uri.js
@@ -161,7 +161,7 @@
162162 uri.query.replace( /(?:^|&)([^&=]*)(?:(=)([^&]*))?/g, function ($0, $1, $2, $3) {
163163 if ( $1 ) {
164164 var k = mw.Uri.decode( $1 );
165 - var v = ($2 == '') ? null : mw.Uri.decode( $3 );
 165+ var v = ( $2 === '' || typeof $2 === 'undefined' ) ? null : mw.Uri.decode( $3 );
166166 if ( typeof q[ k ] === 'string' ) {
167167 q[ k ] = [ q[ k ] ];
168168 }

Comments

#Comment by Brion VIBBER (talk | contribs)   17:45, 13 June 2011

In a quick isolated test in Firefox 4 I can't reproduce getting an undefined value for $2 here even when there isn't a parameter match:

'aaa'.replace( /(?:^|&)([^&=]*)(?:(=)([^&]*))?/g, function ($0, $1, $2, $3) {
  console.log('0='+ JSON.stringify($0),'1='+JSON.stringify($1),'2='+JSON.stringify($2),'3='+JSON.stringify($3));
});

0="aaa" 1="aaa" 2="" 3=""

Hmmm.... actually in Chrome I do get back undefined for $2 and $3 here, while Firefox gives me strings. Sigh.... nothing's ever easy. ;)

Status & tagging log