mediawiki.Title: Add 'params' parameter to #getUrl
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 16 Nov 2013 13:22:54 +0000 (14:22 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 16 Nov 2013 13:22:54 +0000 (14:22 +0100)
Same as the parameter to mw.util.getUrl(). Also prettify the docs there.

Change-Id: I94489e7d526d69126f3e90b7f41e2ec0430f7f66

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

index dde5abf..481b792 100644 (file)
                 * 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 );
                },
 
                /**
index a057cce..86f06b8 100644 (file)
                 * 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 ) {
index f0bb0fc..2556cde 100644 (file)
 
        } );
 
-       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' );