X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.Uri.js;h=d0ed6592ec3cb5192a69c145fcd501cf86e7a420;hb=c0fb8a883633f110a8083a164672e8334714d450;hp=29b224ee6aeb65aa79629a8daa3f10123e88c115;hpb=4f21e6be661f7305abc223bb31600970a3fb5326;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.Uri.js b/resources/src/mediawiki/mediawiki.Uri.js index 29b224ee6a..d0ed6592ec 100644 --- a/resources/src/mediawiki/mediawiki.Uri.js +++ b/resources/src/mediawiki/mediawiki.Uri.js @@ -50,7 +50,11 @@ * @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 */ } /** @@ -84,10 +87,10 @@ * @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. @@ -158,12 +161,11 @@ }() ); /** - * @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 @@ -175,7 +177,6 @@ * @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(); @@ -276,7 +277,8 @@ */ 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 ); @@ -298,7 +300,7 @@ // 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