Followup r95332 (bug 30441 fix) -- Roan pointed out that I forgot to do a global...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 24 Aug 2011 22:09:34 +0000 (22:09 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 24 Aug 2011 22:09:34 +0000 (22:09 +0000)
Now works with parameters containing multiple spaces. :)

resources/mediawiki/mediawiki.util.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index 529d7c9..e8a1777 100644 (file)
                        if ( m && m.length > 1 ) {
                                // Beware that decodeURIComponent is not required to understand '+'
                                // by spec, as encodeURIComponent does not produce it.
-                               return decodeURIComponent( m[1].replace( '+', '%20' ) );
+                               return decodeURIComponent( m[1].replace( /\+/g, '%20' ) );
                        }
                        return null;
                },
index ee16fe7..f51705d 100644 (file)
@@ -107,7 +107,7 @@ test( 'toggleToc', function() {
 });
 
 test( 'getParamValue', function() {
-       expect(4);
+       expect(5);
 
        var     url1 = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad';
 
@@ -119,6 +119,9 @@ test( 'getParamValue', function() {
 
        var url3 = 'example.com?' + $.param({ 'TEST': 'a b+c' });
        strictEqual( mw.util.getParamValue( 'TEST', url3 ), 'a b+c', 'Bug 30441: getParamValue must understand "+" encoding of space' );
+
+       var url4 = 'example.com?' + $.param({ 'TEST': 'a b+c d' }); // check for sloppy code from r95332 :)
+       strictEqual( mw.util.getParamValue( 'TEST', url4 ), 'a b+c d', 'Bug 30441: getParamValue must understand "+" encoding of space (multiple spaces)' );
 });
 
 test( 'tooltipAccessKey', function() {