wp/wp-includes/js/dist/url.js
changeset 9 177826044cd9
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
       
     1 this["wp"] = this["wp"] || {}; this["wp"]["url"] =
       
     2 /******/ (function(modules) { // webpackBootstrap
       
     3 /******/ 	// The module cache
       
     4 /******/ 	var installedModules = {};
       
     5 /******/
       
     6 /******/ 	// The require function
       
     7 /******/ 	function __webpack_require__(moduleId) {
       
     8 /******/
       
     9 /******/ 		// Check if module is in cache
       
    10 /******/ 		if(installedModules[moduleId]) {
       
    11 /******/ 			return installedModules[moduleId].exports;
       
    12 /******/ 		}
       
    13 /******/ 		// Create a new module (and put it into the cache)
       
    14 /******/ 		var module = installedModules[moduleId] = {
       
    15 /******/ 			i: moduleId,
       
    16 /******/ 			l: false,
       
    17 /******/ 			exports: {}
       
    18 /******/ 		};
       
    19 /******/
       
    20 /******/ 		// Execute the module function
       
    21 /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
       
    22 /******/
       
    23 /******/ 		// Flag the module as loaded
       
    24 /******/ 		module.l = true;
       
    25 /******/
       
    26 /******/ 		// Return the exports of the module
       
    27 /******/ 		return module.exports;
       
    28 /******/ 	}
       
    29 /******/
       
    30 /******/
       
    31 /******/ 	// expose the modules object (__webpack_modules__)
       
    32 /******/ 	__webpack_require__.m = modules;
       
    33 /******/
       
    34 /******/ 	// expose the module cache
       
    35 /******/ 	__webpack_require__.c = installedModules;
       
    36 /******/
       
    37 /******/ 	// define getter function for harmony exports
       
    38 /******/ 	__webpack_require__.d = function(exports, name, getter) {
       
    39 /******/ 		if(!__webpack_require__.o(exports, name)) {
       
    40 /******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
       
    41 /******/ 		}
       
    42 /******/ 	};
       
    43 /******/
       
    44 /******/ 	// define __esModule on exports
       
    45 /******/ 	__webpack_require__.r = function(exports) {
       
    46 /******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
       
    47 /******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
       
    48 /******/ 		}
       
    49 /******/ 		Object.defineProperty(exports, '__esModule', { value: true });
       
    50 /******/ 	};
       
    51 /******/
       
    52 /******/ 	// create a fake namespace object
       
    53 /******/ 	// mode & 1: value is a module id, require it
       
    54 /******/ 	// mode & 2: merge all properties of value into the ns
       
    55 /******/ 	// mode & 4: return value when already ns object
       
    56 /******/ 	// mode & 8|1: behave like require
       
    57 /******/ 	__webpack_require__.t = function(value, mode) {
       
    58 /******/ 		if(mode & 1) value = __webpack_require__(value);
       
    59 /******/ 		if(mode & 8) return value;
       
    60 /******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
       
    61 /******/ 		var ns = Object.create(null);
       
    62 /******/ 		__webpack_require__.r(ns);
       
    63 /******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
       
    64 /******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
       
    65 /******/ 		return ns;
       
    66 /******/ 	};
       
    67 /******/
       
    68 /******/ 	// getDefaultExport function for compatibility with non-harmony modules
       
    69 /******/ 	__webpack_require__.n = function(module) {
       
    70 /******/ 		var getter = module && module.__esModule ?
       
    71 /******/ 			function getDefault() { return module['default']; } :
       
    72 /******/ 			function getModuleExports() { return module; };
       
    73 /******/ 		__webpack_require__.d(getter, 'a', getter);
       
    74 /******/ 		return getter;
       
    75 /******/ 	};
       
    76 /******/
       
    77 /******/ 	// Object.prototype.hasOwnProperty.call
       
    78 /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
       
    79 /******/
       
    80 /******/ 	// __webpack_public_path__
       
    81 /******/ 	__webpack_require__.p = "";
       
    82 /******/
       
    83 /******/
       
    84 /******/ 	// Load entry module and return exports
       
    85 /******/ 	return __webpack_require__(__webpack_require__.s = 354);
       
    86 /******/ })
       
    87 /************************************************************************/
       
    88 /******/ ({
       
    89 
       
    90 /***/ 201:
       
    91 /***/ (function(module, exports, __webpack_require__) {
       
    92 
       
    93 "use strict";
       
    94 
       
    95 
       
    96 var has = Object.prototype.hasOwnProperty;
       
    97 
       
    98 var hexTable = (function () {
       
    99     var array = [];
       
   100     for (var i = 0; i < 256; ++i) {
       
   101         array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
       
   102     }
       
   103 
       
   104     return array;
       
   105 }());
       
   106 
       
   107 var compactQueue = function compactQueue(queue) {
       
   108     while (queue.length > 1) {
       
   109         var item = queue.pop();
       
   110         var obj = item.obj[item.prop];
       
   111 
       
   112         if (Array.isArray(obj)) {
       
   113             var compacted = [];
       
   114 
       
   115             for (var j = 0; j < obj.length; ++j) {
       
   116                 if (typeof obj[j] !== 'undefined') {
       
   117                     compacted.push(obj[j]);
       
   118                 }
       
   119             }
       
   120 
       
   121             item.obj[item.prop] = compacted;
       
   122         }
       
   123     }
       
   124 };
       
   125 
       
   126 var arrayToObject = function arrayToObject(source, options) {
       
   127     var obj = options && options.plainObjects ? Object.create(null) : {};
       
   128     for (var i = 0; i < source.length; ++i) {
       
   129         if (typeof source[i] !== 'undefined') {
       
   130             obj[i] = source[i];
       
   131         }
       
   132     }
       
   133 
       
   134     return obj;
       
   135 };
       
   136 
       
   137 var merge = function merge(target, source, options) {
       
   138     if (!source) {
       
   139         return target;
       
   140     }
       
   141 
       
   142     if (typeof source !== 'object') {
       
   143         if (Array.isArray(target)) {
       
   144             target.push(source);
       
   145         } else if (typeof target === 'object') {
       
   146             if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
       
   147                 target[source] = true;
       
   148             }
       
   149         } else {
       
   150             return [target, source];
       
   151         }
       
   152 
       
   153         return target;
       
   154     }
       
   155 
       
   156     if (typeof target !== 'object') {
       
   157         return [target].concat(source);
       
   158     }
       
   159 
       
   160     var mergeTarget = target;
       
   161     if (Array.isArray(target) && !Array.isArray(source)) {
       
   162         mergeTarget = arrayToObject(target, options);
       
   163     }
       
   164 
       
   165     if (Array.isArray(target) && Array.isArray(source)) {
       
   166         source.forEach(function (item, i) {
       
   167             if (has.call(target, i)) {
       
   168                 if (target[i] && typeof target[i] === 'object') {
       
   169                     target[i] = merge(target[i], item, options);
       
   170                 } else {
       
   171                     target.push(item);
       
   172                 }
       
   173             } else {
       
   174                 target[i] = item;
       
   175             }
       
   176         });
       
   177         return target;
       
   178     }
       
   179 
       
   180     return Object.keys(source).reduce(function (acc, key) {
       
   181         var value = source[key];
       
   182 
       
   183         if (has.call(acc, key)) {
       
   184             acc[key] = merge(acc[key], value, options);
       
   185         } else {
       
   186             acc[key] = value;
       
   187         }
       
   188         return acc;
       
   189     }, mergeTarget);
       
   190 };
       
   191 
       
   192 var assign = function assignSingleSource(target, source) {
       
   193     return Object.keys(source).reduce(function (acc, key) {
       
   194         acc[key] = source[key];
       
   195         return acc;
       
   196     }, target);
       
   197 };
       
   198 
       
   199 var decode = function (str, decoder, charset) {
       
   200     var strWithoutPlus = str.replace(/\+/g, ' ');
       
   201     if (charset === 'iso-8859-1') {
       
   202         // unescape never throws, no try...catch needed:
       
   203         return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
       
   204     }
       
   205     // utf-8
       
   206     try {
       
   207         return decodeURIComponent(strWithoutPlus);
       
   208     } catch (e) {
       
   209         return strWithoutPlus;
       
   210     }
       
   211 };
       
   212 
       
   213 var encode = function encode(str, defaultEncoder, charset) {
       
   214     // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
       
   215     // It has been adapted here for stricter adherence to RFC 3986
       
   216     if (str.length === 0) {
       
   217         return str;
       
   218     }
       
   219 
       
   220     var string = typeof str === 'string' ? str : String(str);
       
   221 
       
   222     if (charset === 'iso-8859-1') {
       
   223         return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
       
   224             return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
       
   225         });
       
   226     }
       
   227 
       
   228     var out = '';
       
   229     for (var i = 0; i < string.length; ++i) {
       
   230         var c = string.charCodeAt(i);
       
   231 
       
   232         if (
       
   233             c === 0x2D // -
       
   234             || c === 0x2E // .
       
   235             || c === 0x5F // _
       
   236             || c === 0x7E // ~
       
   237             || (c >= 0x30 && c <= 0x39) // 0-9
       
   238             || (c >= 0x41 && c <= 0x5A) // a-z
       
   239             || (c >= 0x61 && c <= 0x7A) // A-Z
       
   240         ) {
       
   241             out += string.charAt(i);
       
   242             continue;
       
   243         }
       
   244 
       
   245         if (c < 0x80) {
       
   246             out = out + hexTable[c];
       
   247             continue;
       
   248         }
       
   249 
       
   250         if (c < 0x800) {
       
   251             out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
       
   252             continue;
       
   253         }
       
   254 
       
   255         if (c < 0xD800 || c >= 0xE000) {
       
   256             out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
       
   257             continue;
       
   258         }
       
   259 
       
   260         i += 1;
       
   261         c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
       
   262         out += hexTable[0xF0 | (c >> 18)]
       
   263             + hexTable[0x80 | ((c >> 12) & 0x3F)]
       
   264             + hexTable[0x80 | ((c >> 6) & 0x3F)]
       
   265             + hexTable[0x80 | (c & 0x3F)];
       
   266     }
       
   267 
       
   268     return out;
       
   269 };
       
   270 
       
   271 var compact = function compact(value) {
       
   272     var queue = [{ obj: { o: value }, prop: 'o' }];
       
   273     var refs = [];
       
   274 
       
   275     for (var i = 0; i < queue.length; ++i) {
       
   276         var item = queue[i];
       
   277         var obj = item.obj[item.prop];
       
   278 
       
   279         var keys = Object.keys(obj);
       
   280         for (var j = 0; j < keys.length; ++j) {
       
   281             var key = keys[j];
       
   282             var val = obj[key];
       
   283             if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
       
   284                 queue.push({ obj: obj, prop: key });
       
   285                 refs.push(val);
       
   286             }
       
   287         }
       
   288     }
       
   289 
       
   290     compactQueue(queue);
       
   291 
       
   292     return value;
       
   293 };
       
   294 
       
   295 var isRegExp = function isRegExp(obj) {
       
   296     return Object.prototype.toString.call(obj) === '[object RegExp]';
       
   297 };
       
   298 
       
   299 var isBuffer = function isBuffer(obj) {
       
   300     if (obj === null || typeof obj === 'undefined') {
       
   301         return false;
       
   302     }
       
   303 
       
   304     return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
       
   305 };
       
   306 
       
   307 var combine = function combine(a, b) {
       
   308     return [].concat(a, b);
       
   309 };
       
   310 
       
   311 module.exports = {
       
   312     arrayToObject: arrayToObject,
       
   313     assign: assign,
       
   314     combine: combine,
       
   315     compact: compact,
       
   316     decode: decode,
       
   317     encode: encode,
       
   318     isBuffer: isBuffer,
       
   319     isRegExp: isRegExp,
       
   320     merge: merge
       
   321 };
       
   322 
       
   323 
       
   324 /***/ }),
       
   325 
       
   326 /***/ 202:
       
   327 /***/ (function(module, exports, __webpack_require__) {
       
   328 
       
   329 "use strict";
       
   330 
       
   331 
       
   332 var replace = String.prototype.replace;
       
   333 var percentTwenties = /%20/g;
       
   334 
       
   335 module.exports = {
       
   336     'default': 'RFC3986',
       
   337     formatters: {
       
   338         RFC1738: function (value) {
       
   339             return replace.call(value, percentTwenties, '+');
       
   340         },
       
   341         RFC3986: function (value) {
       
   342             return value;
       
   343         }
       
   344     },
       
   345     RFC1738: 'RFC1738',
       
   346     RFC3986: 'RFC3986'
       
   347 };
       
   348 
       
   349 
       
   350 /***/ }),
       
   351 
       
   352 /***/ 354:
       
   353 /***/ (function(module, __webpack_exports__, __webpack_require__) {
       
   354 
       
   355 "use strict";
       
   356 __webpack_require__.r(__webpack_exports__);
       
   357 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isURL", function() { return isURL; });
       
   358 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getProtocol", function() { return getProtocol; });
       
   359 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return isValidProtocol; });
       
   360 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAuthority", function() { return getAuthority; });
       
   361 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return isValidAuthority; });
       
   362 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPath", function() { return getPath; });
       
   363 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidPath", function() { return isValidPath; });
       
   364 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryString", function() { return getQueryString; });
       
   365 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return isValidQueryString; });
       
   366 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFragment", function() { return getFragment; });
       
   367 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return isValidFragment; });
       
   368 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return addQueryArgs; });
       
   369 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return getQueryArg; });
       
   370 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return hasQueryArg; });
       
   371 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return removeQueryArgs; });
       
   372 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return prependHTTP; });
       
   373 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return safeDecodeURI; });
       
   374 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return filterURLForDisplay; });
       
   375 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURIComponent", function() { return safeDecodeURIComponent; });
       
   376 /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(86);
       
   377 /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_0__);
       
   378 /**
       
   379  * External dependencies
       
   380  */
       
   381 
       
   382 var URL_REGEXP = /^(?:https?:)?\/\/\S+$/i;
       
   383 var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
       
   384 var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
       
   385 /**
       
   386  * Determines whether the given string looks like a URL.
       
   387  *
       
   388  * @param {string} url The string to scrutinise.
       
   389  *
       
   390  * @example
       
   391  * ```js
       
   392  * const isURL = isURL( 'https://wordpress.org' ); // true
       
   393  * ```
       
   394  *
       
   395  * @return {boolean} Whether or not it looks like a URL.
       
   396  */
       
   397 
       
   398 function isURL(url) {
       
   399   return URL_REGEXP.test(url);
       
   400 }
       
   401 /**
       
   402  * Returns the protocol part of the URL.
       
   403  *
       
   404  * @param {string} url The full URL.
       
   405  *
       
   406  * @example
       
   407  * ```js
       
   408  * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'
       
   409  * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'
       
   410  * ```
       
   411  *
       
   412  * @return {?string} The protocol part of the URL.
       
   413  */
       
   414 
       
   415 function getProtocol(url) {
       
   416   var matches = /^([^\s:]+:)/.exec(url);
       
   417 
       
   418   if (matches) {
       
   419     return matches[1];
       
   420   }
       
   421 }
       
   422 /**
       
   423  * Tests if a url protocol is valid.
       
   424  *
       
   425  * @param {string} protocol The url protocol.
       
   426  *
       
   427  * @example
       
   428  * ```js
       
   429  * const isValid = isValidProtocol( 'https:' ); // true
       
   430  * const isNotValid = isValidProtocol( 'https :' ); // false
       
   431  * ```
       
   432  *
       
   433  * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:).
       
   434  */
       
   435 
       
   436 function isValidProtocol(protocol) {
       
   437   if (!protocol) {
       
   438     return false;
       
   439   }
       
   440 
       
   441   return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol);
       
   442 }
       
   443 /**
       
   444  * Returns the authority part of the URL.
       
   445  *
       
   446  * @param {string} url The full URL.
       
   447  *
       
   448  * @example
       
   449  * ```js
       
   450  * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'
       
   451  * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
       
   452  * ```
       
   453  *
       
   454  * @return {?string} The authority part of the URL.
       
   455  */
       
   456 
       
   457 function getAuthority(url) {
       
   458   var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
       
   459 
       
   460   if (matches) {
       
   461     return matches[1];
       
   462   }
       
   463 }
       
   464 /**
       
   465  * Checks for invalid characters within the provided authority.
       
   466  *
       
   467  * @param {string} authority A string containing the URL authority.
       
   468  *
       
   469  * @example
       
   470  * ```js
       
   471  * const isValid = isValidAuthority( 'wordpress.org' ); // true
       
   472  * const isNotValid = isValidAuthority( 'wordpress#org' ); // false
       
   473  * ```
       
   474  *
       
   475  * @return {boolean} True if the argument contains a valid authority.
       
   476  */
       
   477 
       
   478 function isValidAuthority(authority) {
       
   479   if (!authority) {
       
   480     return false;
       
   481   }
       
   482 
       
   483   return /^[^\s#?]+$/.test(authority);
       
   484 }
       
   485 /**
       
   486  * Returns the path part of the URL.
       
   487  *
       
   488  * @param {string} url The full URL.
       
   489  *
       
   490  * @example
       
   491  * ```js
       
   492  * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'
       
   493  * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'
       
   494  * ```
       
   495  *
       
   496  * @return {?string} The path part of the URL.
       
   497  */
       
   498 
       
   499 function getPath(url) {
       
   500   var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
       
   501 
       
   502   if (matches) {
       
   503     return matches[1];
       
   504   }
       
   505 }
       
   506 /**
       
   507  * Checks for invalid characters within the provided path.
       
   508  *
       
   509  * @param {string} path The URL path.
       
   510  *
       
   511  * @example
       
   512  * ```js
       
   513  * const isValid = isValidPath( 'test/path/' ); // true
       
   514  * const isNotValid = isValidPath( '/invalid?test/path/' ); // false
       
   515  * ```
       
   516  *
       
   517  * @return {boolean} True if the argument contains a valid path
       
   518  */
       
   519 
       
   520 function isValidPath(path) {
       
   521   if (!path) {
       
   522     return false;
       
   523   }
       
   524 
       
   525   return /^[^\s#?]+$/.test(path);
       
   526 }
       
   527 /**
       
   528  * Returns the query string part of the URL.
       
   529  *
       
   530  * @param {string} url The full URL.
       
   531  *
       
   532  * @example
       
   533  * ```js
       
   534  * const queryString1 = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
       
   535  * const queryString2 = getQueryString( 'https://wordpress.org#fragment?query=false&search=hello' ); // 'query=false&search=hello'
       
   536  * ```
       
   537  *
       
   538  * @return {?string} The query string part of the URL.
       
   539  */
       
   540 
       
   541 function getQueryString(url) {
       
   542   var matches = /^\S+?\?([^\s#]+)/.exec(url);
       
   543 
       
   544   if (matches) {
       
   545     return matches[1];
       
   546   }
       
   547 }
       
   548 /**
       
   549  * Checks for invalid characters within the provided query string.
       
   550  *
       
   551  * @param {string} queryString The query string.
       
   552  *
       
   553  * @example
       
   554  * ```js
       
   555  * const isValid = isValidQueryString( 'query=true&another=false' ); // true
       
   556  * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false
       
   557  * ```
       
   558  *
       
   559  * @return {boolean} True if the argument contains a valid query string.
       
   560  */
       
   561 
       
   562 function isValidQueryString(queryString) {
       
   563   if (!queryString) {
       
   564     return false;
       
   565   }
       
   566 
       
   567   return /^[^\s#?\/]+$/.test(queryString);
       
   568 }
       
   569 /**
       
   570  * Returns the fragment part of the URL.
       
   571  *
       
   572  * @param {string} url The full URL
       
   573  *
       
   574  * @example
       
   575  * ```js
       
   576  * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
       
   577  * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
       
   578  * ```
       
   579  *
       
   580  * @return {?string} The fragment part of the URL.
       
   581  */
       
   582 
       
   583 function getFragment(url) {
       
   584   var matches = /^\S+?(#[^\s\?]*)/.exec(url);
       
   585 
       
   586   if (matches) {
       
   587     return matches[1];
       
   588   }
       
   589 }
       
   590 /**
       
   591  * Checks for invalid characters within the provided fragment.
       
   592  *
       
   593  * @param {string} fragment The url fragment.
       
   594  *
       
   595  * @example
       
   596  * ```js
       
   597  * const isValid = isValidFragment( '#valid-fragment' ); // true
       
   598  * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
       
   599  * ```
       
   600  *
       
   601  * @return {boolean} True if the argument contains a valid fragment.
       
   602  */
       
   603 
       
   604 function isValidFragment(fragment) {
       
   605   if (!fragment) {
       
   606     return false;
       
   607   }
       
   608 
       
   609   return /^#[^\s#?\/]*$/.test(fragment);
       
   610 }
       
   611 /**
       
   612  * Appends arguments as querystring to the provided URL. If the URL already
       
   613  * includes query arguments, the arguments are merged with (and take precedent
       
   614  * over) the existing set.
       
   615  *
       
   616  * @param {?string} url  URL to which arguments should be appended. If omitted,
       
   617  *                       only the resulting querystring is returned.
       
   618  * @param {Object}  args Query arguments to apply to URL.
       
   619  *
       
   620  * @example
       
   621  * ```js
       
   622  * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
       
   623  * ```
       
   624  *
       
   625  * @return {string} URL with arguments applied.
       
   626  */
       
   627 
       
   628 function addQueryArgs() {
       
   629   var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
       
   630   var args = arguments.length > 1 ? arguments[1] : undefined;
       
   631 
       
   632   // If no arguments are to be appended, return original URL.
       
   633   if (!args || !Object.keys(args).length) {
       
   634     return url;
       
   635   }
       
   636 
       
   637   var baseUrl = url; // Determine whether URL already had query arguments.
       
   638 
       
   639   var queryStringIndex = url.indexOf('?');
       
   640 
       
   641   if (queryStringIndex !== -1) {
       
   642     // Merge into existing query arguments.
       
   643     args = Object.assign(Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)), args); // Change working base URL to omit previous query arguments.
       
   644 
       
   645     baseUrl = baseUrl.substr(0, queryStringIndex);
       
   646   }
       
   647 
       
   648   return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(args);
       
   649 }
       
   650 /**
       
   651  * Returns a single query argument of the url
       
   652  *
       
   653  * @param {string} url URL
       
   654  * @param {string} arg Query arg name
       
   655  *
       
   656  * @example
       
   657  * ```js
       
   658  * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar
       
   659  * ```
       
   660  *
       
   661  * @return {Array|string} Query arg value.
       
   662  */
       
   663 
       
   664 function getQueryArg(url, arg) {
       
   665   var queryStringIndex = url.indexOf('?');
       
   666   var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {};
       
   667   return query[arg];
       
   668 }
       
   669 /**
       
   670  * Determines whether the URL contains a given query arg.
       
   671  *
       
   672  * @param {string} url URL
       
   673  * @param {string} arg Query arg name
       
   674  *
       
   675  * @example
       
   676  * ```js
       
   677  * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
       
   678  * ```
       
   679  *
       
   680  * @return {boolean} Whether or not the URL contains the query arg.
       
   681  */
       
   682 
       
   683 function hasQueryArg(url, arg) {
       
   684   return getQueryArg(url, arg) !== undefined;
       
   685 }
       
   686 /**
       
   687  * Removes arguments from the query string of the url
       
   688  *
       
   689  * @param {string} url  URL
       
   690  * @param {...string} args Query Args
       
   691  *
       
   692  * @example
       
   693  * ```js
       
   694  * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
       
   695  * ```
       
   696  *
       
   697  * @return {string} Updated URL
       
   698  */
       
   699 
       
   700 function removeQueryArgs(url) {
       
   701   var queryStringIndex = url.indexOf('?');
       
   702   var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {};
       
   703   var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url;
       
   704 
       
   705   for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
       
   706     args[_key - 1] = arguments[_key];
       
   707   }
       
   708 
       
   709   args.forEach(function (arg) {
       
   710     return delete query[arg];
       
   711   });
       
   712   return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(query);
       
   713 }
       
   714 /**
       
   715  * Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
       
   716  *
       
   717  * @param  {string} url The URL to test
       
   718  *
       
   719  * @example
       
   720  * ```js
       
   721  * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org
       
   722  * ```
       
   723  *
       
   724  * @return {string}     The updated URL
       
   725  */
       
   726 
       
   727 function prependHTTP(url) {
       
   728   if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) {
       
   729     return 'http://' + url;
       
   730   }
       
   731 
       
   732   return url;
       
   733 }
       
   734 /**
       
   735  * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
       
   736  * `decodeURI` throws an error.
       
   737  *
       
   738  * @param {string} uri URI to decode.
       
   739  *
       
   740  * @example
       
   741  * ```js
       
   742  * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
       
   743  * ```
       
   744  *
       
   745  * @return {string} Decoded URI if possible.
       
   746  */
       
   747 
       
   748 function safeDecodeURI(uri) {
       
   749   try {
       
   750     return decodeURI(uri);
       
   751   } catch (uriError) {
       
   752     return uri;
       
   753   }
       
   754 }
       
   755 /**
       
   756  * Returns a URL for display.
       
   757  *
       
   758  * @param {string} url Original URL.
       
   759  *
       
   760  * @example
       
   761  * ```js
       
   762  * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
       
   763  * ```
       
   764  *
       
   765  * @return {string} Displayed URL.
       
   766  */
       
   767 
       
   768 function filterURLForDisplay(url) {
       
   769   // Remove protocol and www prefixes.
       
   770   var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
       
   771 
       
   772   if (filteredURL.match(/^[^\/]+\/$/)) {
       
   773     return filteredURL.replace('/', '');
       
   774   }
       
   775 
       
   776   return filteredURL;
       
   777 }
       
   778 /**
       
   779  * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
       
   780  * `decodeURIComponent` throws an error.
       
   781  *
       
   782  * @param {string} uriComponent URI component to decode.
       
   783  *
       
   784  * @return {string} Decoded URI component if possible.
       
   785  */
       
   786 
       
   787 function safeDecodeURIComponent(uriComponent) {
       
   788   try {
       
   789     return decodeURIComponent(uriComponent);
       
   790   } catch (uriComponentError) {
       
   791     return uriComponent;
       
   792   }
       
   793 }
       
   794 
       
   795 
       
   796 /***/ }),
       
   797 
       
   798 /***/ 355:
       
   799 /***/ (function(module, exports, __webpack_require__) {
       
   800 
       
   801 "use strict";
       
   802 
       
   803 
       
   804 var utils = __webpack_require__(201);
       
   805 var formats = __webpack_require__(202);
       
   806 
       
   807 var arrayPrefixGenerators = {
       
   808     brackets: function brackets(prefix) { // eslint-disable-line func-name-matching
       
   809         return prefix + '[]';
       
   810     },
       
   811     indices: function indices(prefix, key) { // eslint-disable-line func-name-matching
       
   812         return prefix + '[' + key + ']';
       
   813     },
       
   814     repeat: function repeat(prefix) { // eslint-disable-line func-name-matching
       
   815         return prefix;
       
   816     }
       
   817 };
       
   818 
       
   819 var isArray = Array.isArray;
       
   820 var push = Array.prototype.push;
       
   821 var pushToArray = function (arr, valueOrArray) {
       
   822     push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
       
   823 };
       
   824 
       
   825 var toISO = Date.prototype.toISOString;
       
   826 
       
   827 var defaults = {
       
   828     addQueryPrefix: false,
       
   829     allowDots: false,
       
   830     charset: 'utf-8',
       
   831     charsetSentinel: false,
       
   832     delimiter: '&',
       
   833     encode: true,
       
   834     encoder: utils.encode,
       
   835     encodeValuesOnly: false,
       
   836     // deprecated
       
   837     indices: false,
       
   838     serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching
       
   839         return toISO.call(date);
       
   840     },
       
   841     skipNulls: false,
       
   842     strictNullHandling: false
       
   843 };
       
   844 
       
   845 var stringify = function stringify( // eslint-disable-line func-name-matching
       
   846     object,
       
   847     prefix,
       
   848     generateArrayPrefix,
       
   849     strictNullHandling,
       
   850     skipNulls,
       
   851     encoder,
       
   852     filter,
       
   853     sort,
       
   854     allowDots,
       
   855     serializeDate,
       
   856     formatter,
       
   857     encodeValuesOnly,
       
   858     charset
       
   859 ) {
       
   860     var obj = object;
       
   861     if (typeof filter === 'function') {
       
   862         obj = filter(prefix, obj);
       
   863     } else if (obj instanceof Date) {
       
   864         obj = serializeDate(obj);
       
   865     }
       
   866 
       
   867     if (obj === null) {
       
   868         if (strictNullHandling) {
       
   869             return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix;
       
   870         }
       
   871 
       
   872         obj = '';
       
   873     }
       
   874 
       
   875     if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
       
   876         if (encoder) {
       
   877             var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset);
       
   878             return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))];
       
   879         }
       
   880         return [formatter(prefix) + '=' + formatter(String(obj))];
       
   881     }
       
   882 
       
   883     var values = [];
       
   884 
       
   885     if (typeof obj === 'undefined') {
       
   886         return values;
       
   887     }
       
   888 
       
   889     var objKeys;
       
   890     if (Array.isArray(filter)) {
       
   891         objKeys = filter;
       
   892     } else {
       
   893         var keys = Object.keys(obj);
       
   894         objKeys = sort ? keys.sort(sort) : keys;
       
   895     }
       
   896 
       
   897     for (var i = 0; i < objKeys.length; ++i) {
       
   898         var key = objKeys[i];
       
   899 
       
   900         if (skipNulls && obj[key] === null) {
       
   901             continue;
       
   902         }
       
   903 
       
   904         if (Array.isArray(obj)) {
       
   905             pushToArray(values, stringify(
       
   906                 obj[key],
       
   907                 generateArrayPrefix(prefix, key),
       
   908                 generateArrayPrefix,
       
   909                 strictNullHandling,
       
   910                 skipNulls,
       
   911                 encoder,
       
   912                 filter,
       
   913                 sort,
       
   914                 allowDots,
       
   915                 serializeDate,
       
   916                 formatter,
       
   917                 encodeValuesOnly,
       
   918                 charset
       
   919             ));
       
   920         } else {
       
   921             pushToArray(values, stringify(
       
   922                 obj[key],
       
   923                 prefix + (allowDots ? '.' + key : '[' + key + ']'),
       
   924                 generateArrayPrefix,
       
   925                 strictNullHandling,
       
   926                 skipNulls,
       
   927                 encoder,
       
   928                 filter,
       
   929                 sort,
       
   930                 allowDots,
       
   931                 serializeDate,
       
   932                 formatter,
       
   933                 encodeValuesOnly,
       
   934                 charset
       
   935             ));
       
   936         }
       
   937     }
       
   938 
       
   939     return values;
       
   940 };
       
   941 
       
   942 module.exports = function (object, opts) {
       
   943     var obj = object;
       
   944     var options = opts ? utils.assign({}, opts) : {};
       
   945 
       
   946     if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
       
   947         throw new TypeError('Encoder has to be a function.');
       
   948     }
       
   949 
       
   950     var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
       
   951     var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
       
   952     var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
       
   953     var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
       
   954     var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder;
       
   955     var sort = typeof options.sort === 'function' ? options.sort : null;
       
   956     var allowDots = typeof options.allowDots === 'undefined' ? defaults.allowDots : !!options.allowDots;
       
   957     var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
       
   958     var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
       
   959     var charset = options.charset || defaults.charset;
       
   960     if (typeof options.charset !== 'undefined' && options.charset !== 'utf-8' && options.charset !== 'iso-8859-1') {
       
   961         throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
       
   962     }
       
   963 
       
   964     if (typeof options.format === 'undefined') {
       
   965         options.format = formats['default'];
       
   966     } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
       
   967         throw new TypeError('Unknown format option provided.');
       
   968     }
       
   969     var formatter = formats.formatters[options.format];
       
   970     var objKeys;
       
   971     var filter;
       
   972 
       
   973     if (typeof options.filter === 'function') {
       
   974         filter = options.filter;
       
   975         obj = filter('', obj);
       
   976     } else if (Array.isArray(options.filter)) {
       
   977         filter = options.filter;
       
   978         objKeys = filter;
       
   979     }
       
   980 
       
   981     var keys = [];
       
   982 
       
   983     if (typeof obj !== 'object' || obj === null) {
       
   984         return '';
       
   985     }
       
   986 
       
   987     var arrayFormat;
       
   988     if (options.arrayFormat in arrayPrefixGenerators) {
       
   989         arrayFormat = options.arrayFormat;
       
   990     } else if ('indices' in options) {
       
   991         arrayFormat = options.indices ? 'indices' : 'repeat';
       
   992     } else {
       
   993         arrayFormat = 'indices';
       
   994     }
       
   995 
       
   996     var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
       
   997 
       
   998     if (!objKeys) {
       
   999         objKeys = Object.keys(obj);
       
  1000     }
       
  1001 
       
  1002     if (sort) {
       
  1003         objKeys.sort(sort);
       
  1004     }
       
  1005 
       
  1006     for (var i = 0; i < objKeys.length; ++i) {
       
  1007         var key = objKeys[i];
       
  1008 
       
  1009         if (skipNulls && obj[key] === null) {
       
  1010             continue;
       
  1011         }
       
  1012         pushToArray(keys, stringify(
       
  1013             obj[key],
       
  1014             key,
       
  1015             generateArrayPrefix,
       
  1016             strictNullHandling,
       
  1017             skipNulls,
       
  1018             encode ? encoder : null,
       
  1019             filter,
       
  1020             sort,
       
  1021             allowDots,
       
  1022             serializeDate,
       
  1023             formatter,
       
  1024             encodeValuesOnly,
       
  1025             charset
       
  1026         ));
       
  1027     }
       
  1028 
       
  1029     var joined = keys.join(delimiter);
       
  1030     var prefix = options.addQueryPrefix === true ? '?' : '';
       
  1031 
       
  1032     if (options.charsetSentinel) {
       
  1033         if (charset === 'iso-8859-1') {
       
  1034             // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
       
  1035             prefix += 'utf8=%26%2310003%3B&';
       
  1036         } else {
       
  1037             // encodeURIComponent('✓')
       
  1038             prefix += 'utf8=%E2%9C%93&';
       
  1039         }
       
  1040     }
       
  1041 
       
  1042     return joined.length > 0 ? prefix + joined : '';
       
  1043 };
       
  1044 
       
  1045 
       
  1046 /***/ }),
       
  1047 
       
  1048 /***/ 356:
       
  1049 /***/ (function(module, exports, __webpack_require__) {
       
  1050 
       
  1051 "use strict";
       
  1052 
       
  1053 
       
  1054 var utils = __webpack_require__(201);
       
  1055 
       
  1056 var has = Object.prototype.hasOwnProperty;
       
  1057 
       
  1058 var defaults = {
       
  1059     allowDots: false,
       
  1060     allowPrototypes: false,
       
  1061     arrayLimit: 20,
       
  1062     charset: 'utf-8',
       
  1063     charsetSentinel: false,
       
  1064     decoder: utils.decode,
       
  1065     delimiter: '&',
       
  1066     depth: 5,
       
  1067     ignoreQueryPrefix: false,
       
  1068     interpretNumericEntities: false,
       
  1069     parameterLimit: 1000,
       
  1070     parseArrays: true,
       
  1071     plainObjects: false,
       
  1072     strictNullHandling: false
       
  1073 };
       
  1074 
       
  1075 var interpretNumericEntities = function (str) {
       
  1076     return str.replace(/&#(\d+);/g, function ($0, numberStr) {
       
  1077         return String.fromCharCode(parseInt(numberStr, 10));
       
  1078     });
       
  1079 };
       
  1080 
       
  1081 // This is what browsers will submit when the ✓ character occurs in an
       
  1082 // application/x-www-form-urlencoded body and the encoding of the page containing
       
  1083 // the form is iso-8859-1, or when the submitted form has an accept-charset
       
  1084 // attribute of iso-8859-1. Presumably also with other charsets that do not contain
       
  1085 // the ✓ character, such as us-ascii.
       
  1086 var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
       
  1087 
       
  1088 // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
       
  1089 var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
       
  1090 
       
  1091 var parseValues = function parseQueryStringValues(str, options) {
       
  1092     var obj = {};
       
  1093     var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
       
  1094     var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
       
  1095     var parts = cleanStr.split(options.delimiter, limit);
       
  1096     var skipIndex = -1; // Keep track of where the utf8 sentinel was found
       
  1097     var i;
       
  1098 
       
  1099     var charset = options.charset;
       
  1100     if (options.charsetSentinel) {
       
  1101         for (i = 0; i < parts.length; ++i) {
       
  1102             if (parts[i].indexOf('utf8=') === 0) {
       
  1103                 if (parts[i] === charsetSentinel) {
       
  1104                     charset = 'utf-8';
       
  1105                 } else if (parts[i] === isoSentinel) {
       
  1106                     charset = 'iso-8859-1';
       
  1107                 }
       
  1108                 skipIndex = i;
       
  1109                 i = parts.length; // The eslint settings do not allow break;
       
  1110             }
       
  1111         }
       
  1112     }
       
  1113 
       
  1114     for (i = 0; i < parts.length; ++i) {
       
  1115         if (i === skipIndex) {
       
  1116             continue;
       
  1117         }
       
  1118         var part = parts[i];
       
  1119 
       
  1120         var bracketEqualsPos = part.indexOf(']=');
       
  1121         var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
       
  1122 
       
  1123         var key, val;
       
  1124         if (pos === -1) {
       
  1125             key = options.decoder(part, defaults.decoder, charset);
       
  1126             val = options.strictNullHandling ? null : '';
       
  1127         } else {
       
  1128             key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
       
  1129             val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);
       
  1130         }
       
  1131 
       
  1132         if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
       
  1133             val = interpretNumericEntities(val);
       
  1134         }
       
  1135         if (has.call(obj, key)) {
       
  1136             obj[key] = utils.combine(obj[key], val);
       
  1137         } else {
       
  1138             obj[key] = val;
       
  1139         }
       
  1140     }
       
  1141 
       
  1142     return obj;
       
  1143 };
       
  1144 
       
  1145 var parseObject = function (chain, val, options) {
       
  1146     var leaf = val;
       
  1147 
       
  1148     for (var i = chain.length - 1; i >= 0; --i) {
       
  1149         var obj;
       
  1150         var root = chain[i];
       
  1151 
       
  1152         if (root === '[]' && options.parseArrays) {
       
  1153             obj = [].concat(leaf);
       
  1154         } else {
       
  1155             obj = options.plainObjects ? Object.create(null) : {};
       
  1156             var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
       
  1157             var index = parseInt(cleanRoot, 10);
       
  1158             if (!options.parseArrays && cleanRoot === '') {
       
  1159                 obj = { 0: leaf };
       
  1160             } else if (
       
  1161                 !isNaN(index)
       
  1162                 && root !== cleanRoot
       
  1163                 && String(index) === cleanRoot
       
  1164                 && index >= 0
       
  1165                 && (options.parseArrays && index <= options.arrayLimit)
       
  1166             ) {
       
  1167                 obj = [];
       
  1168                 obj[index] = leaf;
       
  1169             } else {
       
  1170                 obj[cleanRoot] = leaf;
       
  1171             }
       
  1172         }
       
  1173 
       
  1174         leaf = obj;
       
  1175     }
       
  1176 
       
  1177     return leaf;
       
  1178 };
       
  1179 
       
  1180 var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
       
  1181     if (!givenKey) {
       
  1182         return;
       
  1183     }
       
  1184 
       
  1185     // Transform dot notation to bracket notation
       
  1186     var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
       
  1187 
       
  1188     // The regex chunks
       
  1189 
       
  1190     var brackets = /(\[[^[\]]*])/;
       
  1191     var child = /(\[[^[\]]*])/g;
       
  1192 
       
  1193     // Get the parent
       
  1194 
       
  1195     var segment = brackets.exec(key);
       
  1196     var parent = segment ? key.slice(0, segment.index) : key;
       
  1197 
       
  1198     // Stash the parent if it exists
       
  1199 
       
  1200     var keys = [];
       
  1201     if (parent) {
       
  1202         // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
       
  1203         if (!options.plainObjects && has.call(Object.prototype, parent)) {
       
  1204             if (!options.allowPrototypes) {
       
  1205                 return;
       
  1206             }
       
  1207         }
       
  1208 
       
  1209         keys.push(parent);
       
  1210     }
       
  1211 
       
  1212     // Loop through children appending to the array until we hit depth
       
  1213 
       
  1214     var i = 0;
       
  1215     while ((segment = child.exec(key)) !== null && i < options.depth) {
       
  1216         i += 1;
       
  1217         if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
       
  1218             if (!options.allowPrototypes) {
       
  1219                 return;
       
  1220             }
       
  1221         }
       
  1222         keys.push(segment[1]);
       
  1223     }
       
  1224 
       
  1225     // If there's a remainder, just add whatever is left
       
  1226 
       
  1227     if (segment) {
       
  1228         keys.push('[' + key.slice(segment.index) + ']');
       
  1229     }
       
  1230 
       
  1231     return parseObject(keys, val, options);
       
  1232 };
       
  1233 
       
  1234 module.exports = function (str, opts) {
       
  1235     var options = opts ? utils.assign({}, opts) : {};
       
  1236 
       
  1237     if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
       
  1238         throw new TypeError('Decoder has to be a function.');
       
  1239     }
       
  1240 
       
  1241     options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;
       
  1242     options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
       
  1243     options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
       
  1244     options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
       
  1245     options.parseArrays = options.parseArrays !== false;
       
  1246     options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
       
  1247     options.allowDots = typeof options.allowDots === 'undefined' ? defaults.allowDots : !!options.allowDots;
       
  1248     options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
       
  1249     options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
       
  1250     options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
       
  1251     options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
       
  1252 
       
  1253     if (typeof options.charset !== 'undefined' && options.charset !== 'utf-8' && options.charset !== 'iso-8859-1') {
       
  1254         throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined');
       
  1255     }
       
  1256     if (typeof options.charset === 'undefined') {
       
  1257         options.charset = defaults.charset;
       
  1258     }
       
  1259 
       
  1260     if (str === '' || str === null || typeof str === 'undefined') {
       
  1261         return options.plainObjects ? Object.create(null) : {};
       
  1262     }
       
  1263 
       
  1264     var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
       
  1265     var obj = options.plainObjects ? Object.create(null) : {};
       
  1266 
       
  1267     // Iterate over the keys and setup the new object
       
  1268 
       
  1269     var keys = Object.keys(tempObj);
       
  1270     for (var i = 0; i < keys.length; ++i) {
       
  1271         var key = keys[i];
       
  1272         var newObj = parseKeys(key, tempObj[key], options);
       
  1273         obj = utils.merge(obj, newObj, options);
       
  1274     }
       
  1275 
       
  1276     return utils.compact(obj);
       
  1277 };
       
  1278 
       
  1279 
       
  1280 /***/ }),
       
  1281 
       
  1282 /***/ 86:
       
  1283 /***/ (function(module, exports, __webpack_require__) {
       
  1284 
       
  1285 "use strict";
       
  1286 
       
  1287 
       
  1288 var stringify = __webpack_require__(355);
       
  1289 var parse = __webpack_require__(356);
       
  1290 var formats = __webpack_require__(202);
       
  1291 
       
  1292 module.exports = {
       
  1293     formats: formats,
       
  1294     parse: parse,
       
  1295     stringify: stringify
       
  1296 };
       
  1297 
       
  1298 
       
  1299 /***/ })
       
  1300 
       
  1301 /******/ });