build: Replace jscs+jshint with eslint
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.Uri.js
index 29b224e..d0ed659 100644 (file)
  * @class mw.Uri
  */
 
+/* eslint-disable no-use-before-define */
+
 ( function ( mw, $ ) {
+       var parser, properties;
+
        /**
         * Function that's useful when constructing the URI string -- we frequently encounter the pattern
         * of having to add something to the URI as we go, but only if it's present, and to include a
@@ -68,9 +72,8 @@
                if ( val === undefined || val === null || val === '' ) {
                        return '';
                }
-               /* jshint latedef:false */
+
                return pre + ( raw ? val : mw.Uri.encode( val ) ) + post;
-               /* jshint latedef:true */
        }
 
        /**
         * @static
         * @property {Object} parser
         */
-       var parser = {
+       parser = {
                strict: mw.template.get( 'mediawiki.Uri', 'strict.regexp' ).render(),
                loose: mw.template.get( 'mediawiki.Uri', 'loose.regexp' ).render()
-       },
+       };
 
        /**
         * The order here matches the order of captured matches in the `parser` property regexes.
                }() );
 
                /**
-                * @class mw.Uri
-                * @constructor
-                *
                 * Construct a new URI object. Throws error if arguments are illegal/impossible, or
                 * otherwise don't parse.
                 *
+                * @class mw.Uri
+                * @constructor
                 * @param {Object|string} [uri] URI string, or an Object with appropriate properties (especially
                 *  another URI object to clone). Object must have non-blank `protocol`, `host`, and `path`
                 *  properties. If omitted (or set to `undefined`, `null` or empty string), then an object
                 * @param {boolean} [options.overrideKeys=false] Whether to let duplicate query parameters
                 *  override each other (`true`) or automagically convert them to an array (`false`).
                 */
-               /* jshint latedef:false */
                function Uri( uri, options ) {
                        var prop,
                                defaultUri = getDefaultUri();
                         */
                        parse: function ( str, options ) {
                                var q, matches,
-                                       uri = this;
+                                       uri = this,
+                                       hasOwn = Object.prototype.hasOwnProperty;
 
                                // Apply parser regex and set all properties based on the result
                                matches = parser[ options.strictMode ? 'strict' : 'loose' ].exec( str );
 
                                                        // If overrideKeys, always (re)set top level value.
                                                        // If not overrideKeys but this key wasn't set before, then we set it as well.
-                                                       if ( options.overrideKeys || q[ k ] === undefined ) {
+                                                       if ( options.overrideKeys || !hasOwn.call( q, k ) ) {
                                                                q[ k ] = v;
 
                                                        // Use arrays if overrideKeys is false and key was already seen before