mediawiki.util: Fix jsduck syntax and minor clean up
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 19 Mar 2014 21:34:14 +0000 (22:34 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 27 Mar 2014 03:53:10 +0000 (20:53 -0700)
* Fix indentation of @param comment to not trigger <pre> context.
* Clean up descriptions.
* Apply coding conventions
  - Function call one one line, or one line per argument.
    Avoid arbitrary splitting mid-line when purely for the sake
    of line length.
* Combine string concatenation in one expression instead of
  adding twice.

Change-Id: Id9f2a7cef1c8bf1c01584fbb293d0605fc91337e

resources/mediawiki/mediawiki.util.js

index 082f807..ffafd33 100644 (file)
                /**
                 * Get the link to a page name (relative to `wgServer`),
                 *
-                * @param {string} str Page name to get the link for.
+                * @param {string} str Page name
                 * @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.
+                *  e.g. `{ action: 'edit' }`
+                * @return {string} Url of the page with name of `str`
                 */
                getUrl: function ( str, params ) {
-                       var url = mw.config.get( 'wgArticlePath' ).replace( '$1',
-                               util.wikiUrlencode( typeof str === 'string' ? str : mw.config.get( 'wgPageName' ) ) );
+                       var url = mw.config.get( 'wgArticlePath' ).replace(
+                               '$1',
+                               util.wikiUrlencode( typeof str === 'string' ? str : mw.config.get( 'wgPageName' ) )
+                       );
+
                        if ( params && !$.isEmptyObject( params ) ) {
-                               url += url.indexOf( '?' ) !== -1 ? '&' : '?';
-                               url += $.param( params );
+                               url += ( url.indexOf( '?' ) !== -1 ? '&' : '?' ) + $.param( params );
                        }
+
                        return url;
                },