Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / resources / src / mediawiki.Uri / Uri.js
index 0e5a5ba..4343ecc 100644 (file)
@@ -95,7 +95,7 @@
         *
         * @private
         * @static
-        * @property {Array} properties
+        * @property {string[]} properties
         */
        properties = [
                'protocol',
         */
 
        /**
-        * A factory method to create a Uri class with a default location to resolve relative URLs
+        * A factory method to create an mw.Uri class with a default location to resolve relative URLs
         * against (including protocol-relative URLs).
         *
         * @method
         * @param {string|Function} documentLocation A full url, or function returning one.
         *  If passed a function, the return value may change over time and this will be honoured. (T74334)
         * @member mw
-        * @return {Function} Uri class
+        * @return {Function} An mw.Uri class constructor
         */
        mw.UriRelative = function ( documentLocation ) {
                var getDefaultUri = ( function () {
                 * @param {boolean} [options.strictMode=false] Trigger strict mode parsing of the url.
                 * @param {boolean} [options.overrideKeys=false] Whether to let duplicate query parameters
                 *  override each other (`true`) or automagically convert them to an array (`false`).
+                * @throws {Error} when the query string or fragment contains an unknown % sequence
                 */
                function Uri( uri, options ) {
                        var prop, hrefCur,
                 * @static
                 * @param {string} s String to decode
                 * @return {string} Decoded string
+                * @throws {Error} when the string contains an unknown % sequence
                 */
                Uri.decode = function ( s ) {
                        return decodeURIComponent( s.replace( /\+/g, '%20' ) );
                         * @private
                         * @param {string} str URI, see constructor.
                         * @param {Object} options See constructor.
+                        * @throws {Error} when the query string or fragment contains an unknown % sequence
                         */
                        parse: function ( str, options ) {
                                var q, matches,
                                q = {};
                                // using replace to iterate over a string
                                if ( uri.query ) {
-                                       uri.query.replace( /(?:^|&)([^&=]*)(?:(=)([^&]*))?/g, function ( $0, $1, $2, $3 ) {
-                                               var k, v;
-                                               if ( $1 ) {
-                                                       k = Uri.decode( $1 );
-                                                       v = ( $2 === '' || $2 === undefined ) ? null : Uri.decode( $3 );
+                                       uri.query.replace( /(?:^|&)([^&=]*)(?:(=)([^&]*))?/g, function ( match, k, eq, v ) {
+                                               if ( k ) {
+                                                       k = Uri.decode( k );
+                                                       v = ( eq === '' || eq === undefined ) ? null : Uri.decode( v );
 
                                                        // If overrideKeys, always (re)set top level value.
                                                        // If not overrideKeys but this key wasn't set before, then we set it as well.
                         */
                        getQueryString: function () {
                                var args = [];
-                               // eslint-disable-next-line jquery/no-each-util
+                               // eslint-disable-next-line no-jquery/no-each-util
                                $.each( this.query, function ( key, val ) {
                                        var k = Uri.encode( key ),
                                                vals = Array.isArray( val ) ? val : [ val ];