url.js 41 KB

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