Previously:
Input:
http://alpha.wiki.krinkle.dev/w/index.php?title=Sandbox/2&oldid=611&veaction=edit
Action:
remove query.veaction
Output:
http://alpha.wiki.krinkle.dev/w/index.php?title=Sandbox%2F2&oldid=611
Now the title parameter stays the same.
Change-Id: Ieb9eee450ea8ae3cc97bab12de935c6e7b103842
var k = Uri.encode( key ),
vals = $.isArray( val ) ? val : [ val ];
$.each( vals, function ( i, v ) {
- args.push( k + ( v === null ? '' : '=' + Uri.encode( v ) ) );
+ if ( v === null ) {
+ args.push( k );
+ } else if ( k === 'title' ) {
+ args.push( k + '=' + mw.util.wikiUrlencode( v ) );
+ } else {
+ args.push( k + '=' + Uri.encode( v ) );
+ }
} );
} );
return args.join( '&' );
);
} );
- QUnit.test( 'Parse a uri with simple querystring', 1, function ( assert ) {
+ QUnit.test( '.getQueryString()', 2, function ( assert ) {
var uri = new mw.Uri( 'http://www.google.com/?q=uri' );
assert.deepEqual(
},
'basic object properties'
);
+
+ uri = new mw.Uri( 'https://example.org/mw/index.php?title=Sandbox/7&other=Sandbox/7&foo' );
+ assert.equal(
+ uri.getQueryString(),
+ 'title=Sandbox/7&other=Sandbox%2F7&foo',
+ 'title parameter is escaped the wiki-way'
+ );
+
} );
QUnit.test( 'Handle multiple query parameter (overrideKeys on)', 5, function ( assert ) {