* Get the URL to this title
*
* @see mw.util#getUrl
+ * @param {Object} [params] A mapping of query parameter names to values,
+ * e.g. `{ action: 'edit' }`.
* @return {string}
*/
- getUrl: function () {
- return mw.util.getUrl( this.toString() );
+ getUrl: function ( params ) {
+ return mw.util.getUrl( this.toString(), params );
},
/**
* Get the link to a page name (relative to `wgServer`),
*
* @param {string} str Page name to get the link for.
- * @param {Object} params A mapping of query parameter names to values,
- * e.g. { action: 'edit' }. Optional.
+ * @param {Object} [params] A mapping of query parameter names to values,
+ * e.g. `{ action: 'edit' }`.
* @return {string} Location for a page with name of `str` or boolean false on error.
*/
getUrl: function ( str, params ) {
} );
- QUnit.test( 'getUrl', 2, function ( assert ) {
+ QUnit.test( 'getUrl', 3, function ( assert ) {
var title;
// Config
mw.config.set( 'wgArticlePath', '/wiki/$1' );
title = new mw.Title( 'Foobar' );
- assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, getUrl uses mw.util.getUrl' );
+ assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionality, getUrl uses mw.util.getUrl' );
+ assert.equal( title.getUrl({ action: 'edit' }), '/wiki/Foobar?action=edit', 'Basic functionality, \'params\' parameter' );
title = new mw.Title( 'John Doe', 3 );
assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );