diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/js/dist/url.js --- a/wp/wp-includes/js/dist/url.js Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/js/dist/url.js Tue Dec 15 13:49:49 2020 +0100 @@ -82,18 +82,45 @@ /******/ /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 354); +/******/ return __webpack_require__(__webpack_require__.s = 444); /******/ }) /************************************************************************/ /******/ ({ -/***/ 201: +/***/ 115: +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var stringify = __webpack_require__(433); +var parse = __webpack_require__(434); +var formats = __webpack_require__(259); + +module.exports = { + formats: formats, + parse: parse, + stringify: stringify +}; + + +/***/ }), + +/***/ 2: +/***/ (function(module, exports) { + +(function() { module.exports = this["lodash"]; }()); + +/***/ }), + +/***/ 258: /***/ (function(module, exports, __webpack_require__) { "use strict"; var has = Object.prototype.hasOwnProperty; +var isArray = Array.isArray; var hexTable = (function () { var array = []; @@ -109,7 +136,7 @@ var item = queue.pop(); var obj = item.obj[item.prop]; - if (Array.isArray(obj)) { + if (isArray(obj)) { var compacted = []; for (var j = 0; j < obj.length; ++j) { @@ -140,9 +167,9 @@ } if (typeof source !== 'object') { - if (Array.isArray(target)) { + if (isArray(target)) { target.push(source); - } else if (typeof target === 'object') { + } else if (target && typeof target === 'object') { if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { target[source] = true; } @@ -153,20 +180,21 @@ return target; } - if (typeof target !== 'object') { + if (!target || typeof target !== 'object') { return [target].concat(source); } var mergeTarget = target; - if (Array.isArray(target) && !Array.isArray(source)) { + if (isArray(target) && !isArray(source)) { mergeTarget = arrayToObject(target, options); } - if (Array.isArray(target) && Array.isArray(source)) { + if (isArray(target) && isArray(source)) { source.forEach(function (item, i) { if (has.call(target, i)) { - if (target[i] && typeof target[i] === 'object') { - target[i] = merge(target[i], item, options); + var targetItem = target[i]; + if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { + target[i] = merge(targetItem, item, options); } else { target.push(item); } @@ -297,7 +325,7 @@ }; var isBuffer = function isBuffer(obj) { - if (obj === null || typeof obj === 'undefined') { + if (!obj || typeof obj !== 'object') { return false; } @@ -323,7 +351,7 @@ /***/ }), -/***/ 202: +/***/ 259: /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -349,465 +377,21 @@ /***/ }), -/***/ 354: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isURL", function() { return isURL; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getProtocol", function() { return getProtocol; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return isValidProtocol; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAuthority", function() { return getAuthority; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return isValidAuthority; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPath", function() { return getPath; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidPath", function() { return isValidPath; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryString", function() { return getQueryString; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return isValidQueryString; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFragment", function() { return getFragment; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return isValidFragment; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return addQueryArgs; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return getQueryArg; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return hasQueryArg; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return removeQueryArgs; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return prependHTTP; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return safeDecodeURI; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return filterURLForDisplay; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURIComponent", function() { return safeDecodeURIComponent; }); -/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(86); -/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_0__); -/** - * External dependencies - */ - -var URL_REGEXP = /^(?:https?:)?\/\/\S+$/i; -var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; -var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; -/** - * Determines whether the given string looks like a URL. - * - * @param {string} url The string to scrutinise. - * - * @example - * ```js - * const isURL = isURL( 'https://wordpress.org' ); // true - * ``` - * - * @return {boolean} Whether or not it looks like a URL. - */ - -function isURL(url) { - return URL_REGEXP.test(url); -} -/** - * Returns the protocol part of the URL. - * - * @param {string} url The full URL. - * - * @example - * ```js - * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' - * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' - * ``` - * - * @return {?string} The protocol part of the URL. - */ - -function getProtocol(url) { - var matches = /^([^\s:]+:)/.exec(url); - - if (matches) { - return matches[1]; - } -} -/** - * Tests if a url protocol is valid. - * - * @param {string} protocol The url protocol. - * - * @example - * ```js - * const isValid = isValidProtocol( 'https:' ); // true - * const isNotValid = isValidProtocol( 'https :' ); // false - * ``` - * - * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). - */ - -function isValidProtocol(protocol) { - if (!protocol) { - return false; - } - - return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); -} -/** - * Returns the authority part of the URL. - * - * @param {string} url The full URL. - * - * @example - * ```js - * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' - * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' - * ``` - * - * @return {?string} The authority part of the URL. - */ - -function getAuthority(url) { - var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); - - if (matches) { - return matches[1]; - } -} -/** - * Checks for invalid characters within the provided authority. - * - * @param {string} authority A string containing the URL authority. - * - * @example - * ```js - * const isValid = isValidAuthority( 'wordpress.org' ); // true - * const isNotValid = isValidAuthority( 'wordpress#org' ); // false - * ``` - * - * @return {boolean} True if the argument contains a valid authority. - */ - -function isValidAuthority(authority) { - if (!authority) { - return false; - } - - return /^[^\s#?]+$/.test(authority); -} -/** - * Returns the path part of the URL. - * - * @param {string} url The full URL. - * - * @example - * ```js - * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' - * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' - * ``` - * - * @return {?string} The path part of the URL. - */ - -function getPath(url) { - var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); - - if (matches) { - return matches[1]; - } -} -/** - * Checks for invalid characters within the provided path. - * - * @param {string} path The URL path. - * - * @example - * ```js - * const isValid = isValidPath( 'test/path/' ); // true - * const isNotValid = isValidPath( '/invalid?test/path/' ); // false - * ``` - * - * @return {boolean} True if the argument contains a valid path - */ - -function isValidPath(path) { - if (!path) { - return false; - } - - return /^[^\s#?]+$/.test(path); -} -/** - * Returns the query string part of the URL. - * - * @param {string} url The full URL. - * - * @example - * ```js - * const queryString1 = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' - * const queryString2 = getQueryString( 'https://wordpress.org#fragment?query=false&search=hello' ); // 'query=false&search=hello' - * ``` - * - * @return {?string} The query string part of the URL. - */ - -function getQueryString(url) { - var matches = /^\S+?\?([^\s#]+)/.exec(url); - - if (matches) { - return matches[1]; - } -} -/** - * Checks for invalid characters within the provided query string. - * - * @param {string} queryString The query string. - * - * @example - * ```js - * const isValid = isValidQueryString( 'query=true&another=false' ); // true - * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false - * ``` - * - * @return {boolean} True if the argument contains a valid query string. - */ - -function isValidQueryString(queryString) { - if (!queryString) { - return false; - } - - return /^[^\s#?\/]+$/.test(queryString); -} -/** - * Returns the fragment part of the URL. - * - * @param {string} url The full URL - * - * @example - * ```js - * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' - * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' - * ``` - * - * @return {?string} The fragment part of the URL. - */ - -function getFragment(url) { - var matches = /^\S+?(#[^\s\?]*)/.exec(url); - - if (matches) { - return matches[1]; - } -} -/** - * Checks for invalid characters within the provided fragment. - * - * @param {string} fragment The url fragment. - * - * @example - * ```js - * const isValid = isValidFragment( '#valid-fragment' ); // true - * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false - * ``` - * - * @return {boolean} True if the argument contains a valid fragment. - */ - -function isValidFragment(fragment) { - if (!fragment) { - return false; - } - - return /^#[^\s#?\/]*$/.test(fragment); -} -/** - * Appends arguments as querystring to the provided URL. If the URL already - * includes query arguments, the arguments are merged with (and take precedent - * over) the existing set. - * - * @param {?string} url URL to which arguments should be appended. If omitted, - * only the resulting querystring is returned. - * @param {Object} args Query arguments to apply to URL. - * - * @example - * ```js - * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test - * ``` - * - * @return {string} URL with arguments applied. - */ - -function addQueryArgs() { - var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; - var args = arguments.length > 1 ? arguments[1] : undefined; - - // If no arguments are to be appended, return original URL. - if (!args || !Object.keys(args).length) { - return url; - } - - var baseUrl = url; // Determine whether URL already had query arguments. - - var queryStringIndex = url.indexOf('?'); - - if (queryStringIndex !== -1) { - // Merge into existing query arguments. - args = Object.assign(Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)), args); // Change working base URL to omit previous query arguments. - - baseUrl = baseUrl.substr(0, queryStringIndex); - } - - return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(args); -} -/** - * Returns a single query argument of the url - * - * @param {string} url URL - * @param {string} arg Query arg name - * - * @example - * ```js - * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar - * ``` - * - * @return {Array|string} Query arg value. - */ - -function getQueryArg(url, arg) { - var queryStringIndex = url.indexOf('?'); - var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {}; - return query[arg]; -} -/** - * Determines whether the URL contains a given query arg. - * - * @param {string} url URL - * @param {string} arg Query arg name - * - * @example - * ```js - * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true - * ``` - * - * @return {boolean} Whether or not the URL contains the query arg. - */ - -function hasQueryArg(url, arg) { - return getQueryArg(url, arg) !== undefined; -} -/** - * Removes arguments from the query string of the url - * - * @param {string} url URL - * @param {...string} args Query Args - * - * @example - * ```js - * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar - * ``` - * - * @return {string} Updated URL - */ - -function removeQueryArgs(url) { - var queryStringIndex = url.indexOf('?'); - var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {}; - var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; - - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - args.forEach(function (arg) { - return delete query[arg]; - }); - return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(query); -} -/** - * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. - * - * @param {string} url The URL to test - * - * @example - * ```js - * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org - * ``` - * - * @return {string} The updated URL - */ - -function prependHTTP(url) { - if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) { - return 'http://' + url; - } - - return url; -} -/** - * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if - * `decodeURI` throws an error. - * - * @param {string} uri URI to decode. - * - * @example - * ```js - * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' - * ``` - * - * @return {string} Decoded URI if possible. - */ - -function safeDecodeURI(uri) { - try { - return decodeURI(uri); - } catch (uriError) { - return uri; - } -} -/** - * Returns a URL for display. - * - * @param {string} url Original URL. - * - * @example - * ```js - * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg - * ``` - * - * @return {string} Displayed URL. - */ - -function filterURLForDisplay(url) { - // Remove protocol and www prefixes. - var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. - - if (filteredURL.match(/^[^\/]+\/$/)) { - return filteredURL.replace('/', ''); - } - - return filteredURL; -} -/** - * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if - * `decodeURIComponent` throws an error. - * - * @param {string} uriComponent URI component to decode. - * - * @return {string} Decoded URI component if possible. - */ - -function safeDecodeURIComponent(uriComponent) { - try { - return decodeURIComponent(uriComponent); - } catch (uriComponentError) { - return uriComponent; - } -} - - -/***/ }), - -/***/ 355: +/***/ 433: /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(201); -var formats = __webpack_require__(202); +var utils = __webpack_require__(258); +var formats = __webpack_require__(259); +var has = Object.prototype.hasOwnProperty; var arrayPrefixGenerators = { brackets: function brackets(prefix) { // eslint-disable-line func-name-matching return prefix + '[]'; }, + comma: 'comma', indices: function indices(prefix, key) { // eslint-disable-line func-name-matching return prefix + '[' + key + ']'; }, @@ -833,6 +417,7 @@ encode: true, encoder: utils.encode, encodeValuesOnly: false, + formatter: formats.formatters[formats['default']], // deprecated indices: false, serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching @@ -862,6 +447,8 @@ obj = filter(prefix, obj); } else if (obj instanceof Date) { obj = serializeDate(obj); + } else if (generateArrayPrefix === 'comma' && isArray(obj)) { + obj = obj.join(','); } if (obj === null) { @@ -887,7 +474,7 @@ } var objKeys; - if (Array.isArray(filter)) { + if (isArray(filter)) { objKeys = filter; } else { var keys = Object.keys(obj); @@ -901,10 +488,10 @@ continue; } - if (Array.isArray(obj)) { + if (isArray(obj)) { pushToArray(values, stringify( obj[key], - generateArrayPrefix(prefix, key), + typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix, generateArrayPrefix, strictNullHandling, skipNulls, @@ -939,41 +526,63 @@ return values; }; -module.exports = function (object, opts) { - var obj = object; - var options = opts ? utils.assign({}, opts) : {}; +var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { + if (!opts) { + return defaults; + } - if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { throw new TypeError('Encoder has to be a function.'); } - var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; - var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; - var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; - var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; - var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder; - var sort = typeof options.sort === 'function' ? options.sort : null; - var allowDots = typeof options.allowDots === 'undefined' ? defaults.allowDots : !!options.allowDots; - var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate; - var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly; - var charset = options.charset || defaults.charset; - if (typeof options.charset !== 'undefined' && options.charset !== 'utf-8' && options.charset !== 'iso-8859-1') { - throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); + var charset = opts.charset || defaults.charset; + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); + } + + var format = formats['default']; + if (typeof opts.format !== 'undefined') { + if (!has.call(formats.formatters, opts.format)) { + throw new TypeError('Unknown format option provided.'); + } + format = opts.format; + } + var formatter = formats.formatters[format]; + + var filter = defaults.filter; + if (typeof opts.filter === 'function' || isArray(opts.filter)) { + filter = opts.filter; } - if (typeof options.format === 'undefined') { - options.format = formats['default']; - } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) { - throw new TypeError('Unknown format option provided.'); - } - var formatter = formats.formatters[options.format]; + return { + addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, + delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, + encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, + encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, + encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, + filter: filter, + formatter: formatter, + serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, + skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, + sort: typeof opts.sort === 'function' ? opts.sort : null, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling + }; +}; + +module.exports = function (object, opts) { + var obj = object; + var options = normalizeStringifyOptions(opts); + var objKeys; var filter; if (typeof options.filter === 'function') { filter = options.filter; obj = filter('', obj); - } else if (Array.isArray(options.filter)) { + } else if (isArray(options.filter)) { filter = options.filter; objKeys = filter; } @@ -985,10 +594,10 @@ } var arrayFormat; - if (options.arrayFormat in arrayPrefixGenerators) { - arrayFormat = options.arrayFormat; - } else if ('indices' in options) { - arrayFormat = options.indices ? 'indices' : 'repeat'; + if (opts && opts.arrayFormat in arrayPrefixGenerators) { + arrayFormat = opts.arrayFormat; + } else if (opts && 'indices' in opts) { + arrayFormat = opts.indices ? 'indices' : 'repeat'; } else { arrayFormat = 'indices'; } @@ -999,38 +608,38 @@ objKeys = Object.keys(obj); } - if (sort) { - objKeys.sort(sort); + if (options.sort) { + objKeys.sort(options.sort); } for (var i = 0; i < objKeys.length; ++i) { var key = objKeys[i]; - if (skipNulls && obj[key] === null) { + if (options.skipNulls && obj[key] === null) { continue; } pushToArray(keys, stringify( obj[key], key, generateArrayPrefix, - strictNullHandling, - skipNulls, - encode ? encoder : null, - filter, - sort, - allowDots, - serializeDate, - formatter, - encodeValuesOnly, - charset + options.strictNullHandling, + options.skipNulls, + options.encode ? options.encoder : null, + options.filter, + options.sort, + options.allowDots, + options.serializeDate, + options.formatter, + options.encodeValuesOnly, + options.charset )); } - var joined = keys.join(delimiter); + var joined = keys.join(options.delimiter); var prefix = options.addQueryPrefix === true ? '?' : ''; if (options.charsetSentinel) { - if (charset === 'iso-8859-1') { + if (options.charset === 'iso-8859-1') { // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark prefix += 'utf8=%26%2310003%3B&'; } else { @@ -1045,13 +654,13 @@ /***/ }), -/***/ 356: +/***/ 434: /***/ (function(module, exports, __webpack_require__) { "use strict"; -var utils = __webpack_require__(201); +var utils = __webpack_require__(258); var has = Object.prototype.hasOwnProperty; @@ -1061,6 +670,7 @@ arrayLimit: 20, charset: 'utf-8', charsetSentinel: false, + comma: false, decoder: utils.decode, delimiter: '&', depth: 5, @@ -1132,6 +742,11 @@ if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { val = interpretNumericEntities(val); } + + if (val && options.comma && val.indexOf(',') > -1) { + val = val.split(','); + } + if (has.call(obj, key)) { obj[key] = utils.combine(obj[key], val); } else { @@ -1231,31 +846,41 @@ return parseObject(keys, val, options); }; -module.exports = function (str, opts) { - var options = opts ? utils.assign({}, opts) : {}; +var normalizeParseOptions = function normalizeParseOptions(opts) { + if (!opts) { + return defaults; + } - if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { + if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { throw new TypeError('Decoder has to be a function.'); } - options.ignoreQueryPrefix = options.ignoreQueryPrefix === true; - options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; - options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; - options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; - options.parseArrays = options.parseArrays !== false; - options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; - options.allowDots = typeof options.allowDots === 'undefined' ? defaults.allowDots : !!options.allowDots; - options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; - options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; - options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; - options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; - - if (typeof options.charset !== 'undefined' && options.charset !== 'utf-8' && options.charset !== 'iso-8859-1') { + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); } - if (typeof options.charset === 'undefined') { - options.charset = defaults.charset; - } + var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; + + return { + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, + allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, + arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, + comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, + decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, + delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, + depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth, + ignoreQueryPrefix: opts.ignoreQueryPrefix === true, + interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, + parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, + parseArrays: opts.parseArrays !== false, + plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling + }; +}; + +module.exports = function (str, opts) { + var options = normalizeParseOptions(opts); if (str === '' || str === null || typeof str === 'undefined') { return options.plainObjects ? Object.create(null) : {}; @@ -1279,21 +904,628 @@ /***/ }), -/***/ 86: -/***/ (function(module, exports, __webpack_require__) { +/***/ 444: +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, "isURL", function() { return /* reexport */ isURL; }); +__webpack_require__.d(__webpack_exports__, "isEmail", function() { return /* reexport */ isEmail; }); +__webpack_require__.d(__webpack_exports__, "getProtocol", function() { return /* reexport */ getProtocol; }); +__webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return /* reexport */ isValidProtocol; }); +__webpack_require__.d(__webpack_exports__, "getAuthority", function() { return /* reexport */ getAuthority; }); +__webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return /* reexport */ isValidAuthority; }); +__webpack_require__.d(__webpack_exports__, "getPath", function() { return /* reexport */ getPath; }); +__webpack_require__.d(__webpack_exports__, "isValidPath", function() { return /* reexport */ isValidPath; }); +__webpack_require__.d(__webpack_exports__, "getQueryString", function() { return /* reexport */ getQueryString; }); +__webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return /* reexport */ isValidQueryString; }); +__webpack_require__.d(__webpack_exports__, "getPathAndQueryString", function() { return /* reexport */ getPathAndQueryString; }); +__webpack_require__.d(__webpack_exports__, "getFragment", function() { return /* reexport */ getFragment; }); +__webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return /* reexport */ isValidFragment; }); +__webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return /* reexport */ addQueryArgs; }); +__webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return /* reexport */ getQueryArg; }); +__webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return /* reexport */ hasQueryArg; }); +__webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return /* reexport */ removeQueryArgs; }); +__webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return /* reexport */ prependHTTP; }); +__webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return /* reexport */ safeDecodeURI; }); +__webpack_require__.d(__webpack_exports__, "safeDecodeURIComponent", function() { return /* reexport */ safeDecodeURIComponent; }); +__webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return /* reexport */ filterURLForDisplay; }); +__webpack_require__.d(__webpack_exports__, "cleanForSlug", function() { return /* reexport */ cleanForSlug; }); + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-url.js +/** + * Determines whether the given string looks like a URL. + * + * @param {string} url The string to scrutinise. + * + * @example + * ```js + * const isURL = isURL( 'https://wordpress.org' ); // true + * ``` + * + * @see https://url.spec.whatwg.org/ + * @see https://url.spec.whatwg.org/#valid-url-string + * + * @return {boolean} Whether or not it looks like a URL. + */ +function isURL(url) { + // A URL can be considered value if the `URL` constructor is able to parse + // it. The constructor throws an error for an invalid URL. + try { + new URL(url); + return true; + } catch (_unused) { + return false; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-email.js +var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; +/** + * Determines whether the given string looks like an email. + * + * @param {string} email The string to scrutinise. + * + * @example + * ```js + * const isEmail = isEmail( 'hello@wordpress.org' ); // true + * ``` + * + * @return {boolean} Whether or not it looks like an email. + */ + +function isEmail(email) { + return EMAIL_REGEXP.test(email); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-protocol.js +/** + * Returns the protocol part of the URL. + * + * @param {string} url The full URL. + * + * @example + * ```js + * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' + * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' + * ``` + * + * @return {string|void} The protocol part of the URL. + */ +function getProtocol(url) { + var matches = /^([^\s:]+:)/.exec(url); + + if (matches) { + return matches[1]; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-protocol.js +/** + * Tests if a url protocol is valid. + * + * @param {string} protocol The url protocol. + * + * @example + * ```js + * const isValid = isValidProtocol( 'https:' ); // true + * const isNotValid = isValidProtocol( 'https :' ); // false + * ``` + * + * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). + */ +function isValidProtocol(protocol) { + if (!protocol) { + return false; + } + + return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-authority.js +/** + * Returns the authority part of the URL. + * + * @param {string} url The full URL. + * + * @example + * ```js + * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' + * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' + * ``` + * + * @return {string|void} The authority part of the URL. + */ +function getAuthority(url) { + var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); + + if (matches) { + return matches[1]; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-authority.js +/** + * Checks for invalid characters within the provided authority. + * + * @param {string} authority A string containing the URL authority. + * + * @example + * ```js + * const isValid = isValidAuthority( 'wordpress.org' ); // true + * const isNotValid = isValidAuthority( 'wordpress#org' ); // false + * ``` + * + * @return {boolean} True if the argument contains a valid authority. + */ +function isValidAuthority(authority) { + if (!authority) { + return false; + } + + return /^[^\s#?]+$/.test(authority); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path.js +/** + * Returns the path part of the URL. + * + * @param {string} url The full URL. + * + * @example + * ```js + * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' + * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' + * ``` + * + * @return {string|void} The path part of the URL. + */ +function getPath(url) { + var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); + + if (matches) { + return matches[1]; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-path.js +/** + * Checks for invalid characters within the provided path. + * + * @param {string} path The URL path. + * + * @example + * ```js + * const isValid = isValidPath( 'test/path/' ); // true + * const isNotValid = isValidPath( '/invalid?test/path/' ); // false + * ``` + * + * @return {boolean} True if the argument contains a valid path + */ +function isValidPath(path) { + if (!path) { + return false; + } + + return /^[^\s#?]+$/.test(path); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-string.js +/** + * Returns the query string part of the URL. + * + * @param {string} url The full URL. + * + * @example + * ```js + * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' + * ``` + * + * @return {string|void} The query string part of the URL. + */ +function getQueryString(url) { + var query; + + try { + query = new URL(url).search.substring(1); + } catch (error) {} + + if (query) { + return query; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-query-string.js +/** + * Checks for invalid characters within the provided query string. + * + * @param {string} queryString The query string. + * + * @example + * ```js + * const isValid = isValidQueryString( 'query=true&another=false' ); // true + * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false + * ``` + * + * @return {boolean} True if the argument contains a valid query string. + */ +function isValidQueryString(queryString) { + if (!queryString) { + return false; + } + + return /^[^\s#?\/]+$/.test(queryString); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path-and-query-string.js +/** + * Internal dependencies + */ + +/** + * Returns the path part and query string part of the URL. + * + * @param {string} url The full URL. + * + * @example + * ```js + * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true' + * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq' + * ``` + * + * @return {string} The path part and query string part of the URL. + */ + +function getPathAndQueryString(url) { + var path = getPath(url); + var queryString = getQueryString(url); + var value = '/'; + if (path) value += path; + if (queryString) value += "?".concat(queryString); + return value; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-fragment.js +/** + * Returns the fragment part of the URL. + * + * @param {string} url The full URL + * + * @example + * ```js + * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' + * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' + * ``` + * + * @return {string|void} The fragment part of the URL. + */ +function getFragment(url) { + var matches = /^\S+?(#[^\s\?]*)/.exec(url); + + if (matches) { + return matches[1]; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-fragment.js +/** + * Checks for invalid characters within the provided fragment. + * + * @param {string} fragment The url fragment. + * + * @example + * ```js + * const isValid = isValidFragment( '#valid-fragment' ); // true + * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false + * ``` + * + * @return {boolean} True if the argument contains a valid fragment. + */ +function isValidFragment(fragment) { + if (!fragment) { + return false; + } + + return /^#[^\s#?\/]*$/.test(fragment); +} + +// EXTERNAL MODULE: ./node_modules/qs/lib/index.js +var lib = __webpack_require__(115); + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js +/** + * External dependencies + */ + +/** + * Appends arguments as querystring to the provided URL. If the URL already + * includes query arguments, the arguments are merged with (and take precedent + * over) the existing set. + * + * @param {string} [url=''] URL to which arguments should be appended. If omitted, + * only the resulting querystring is returned. + * @param {Object} [args] Query arguments to apply to URL. + * + * @example + * ```js + * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test + * ``` + * + * @return {string} URL with arguments applied. + */ + +function addQueryArgs() { + var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + var args = arguments.length > 1 ? arguments[1] : undefined; + + // If no arguments are to be appended, return original URL. + if (!args || !Object.keys(args).length) { + return url; + } + + var baseUrl = url; // Determine whether URL already had query arguments. + + var queryStringIndex = url.indexOf('?'); + + if (queryStringIndex !== -1) { + // Merge into existing query arguments. + args = Object.assign(Object(lib["parse"])(url.substr(queryStringIndex + 1)), args); // Change working base URL to omit previous query arguments. + + baseUrl = baseUrl.substr(0, queryStringIndex); + } + + return baseUrl + '?' + Object(lib["stringify"])(args); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js +/** + * External dependencies + */ + +/* eslint-disable jsdoc/valid-types */ + +/** + * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject + */ + +/* eslint-enable */ + +/** + * @typedef {string|string[]|QueryArgObject} QueryArgParsed + */ + +/** + * Returns a single query argument of the url + * + * @param {string} url URL. + * @param {string} arg Query arg name. + * + * @example + * ```js + * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar + * ``` + * + * @return {QueryArgParsed|undefined} Query arg value. + */ + +function getQueryArg(url, arg) { + var queryStringIndex = url.indexOf('?'); + var query = queryStringIndex !== -1 ? Object(lib["parse"])(url.substr(queryStringIndex + 1)) : {}; + return query[arg]; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js +/** + * Internal dependencies + */ + +/** + * Determines whether the URL contains a given query arg. + * + * @param {string} url URL. + * @param {string} arg Query arg name. + * + * @example + * ```js + * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true + * ``` + * + * @return {boolean} Whether or not the URL contains the query arg. + */ + +function hasQueryArg(url, arg) { + return getQueryArg(url, arg) !== undefined; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js +/** + * External dependencies + */ + +/** + * Removes arguments from the query string of the url + * + * @param {string} url URL. + * @param {...string} args Query Args. + * + * @example + * ```js + * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar + * ``` + * + * @return {string} Updated URL. + */ + +function removeQueryArgs(url) { + var queryStringIndex = url.indexOf('?'); + var query = queryStringIndex !== -1 ? Object(lib["parse"])(url.substr(queryStringIndex + 1)) : {}; + var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; + + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + args.forEach(function (arg) { + return delete query[arg]; + }); + return baseUrl + '?' + Object(lib["stringify"])(query); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js +/** + * Internal dependencies + */ + +var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; +/** + * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. + * + * @param {string} url The URL to test. + * + * @example + * ```js + * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org + * ``` + * + * @return {string} The updated URL. + */ + +function prependHTTP(url) { + if (!url) { + return url; + } + + url = url.trim(); + + if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) { + return 'http://' + url; + } + + return url; +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri.js +/** + * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if + * `decodeURI` throws an error. + * + * @param {string} uri URI to decode. + * + * @example + * ```js + * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' + * ``` + * + * @return {string} Decoded URI if possible. + */ +function safeDecodeURI(uri) { + try { + return decodeURI(uri); + } catch (uriError) { + return uri; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri-component.js +/** + * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if + * `decodeURIComponent` throws an error. + * + * @param {string} uriComponent URI component to decode. + * + * @return {string} Decoded URI component if possible. + */ +function safeDecodeURIComponent(uriComponent) { + try { + return decodeURIComponent(uriComponent); + } catch (uriComponentError) { + return uriComponent; + } +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/filter-url-for-display.js +/** + * Returns a URL for display. + * + * @param {string} url Original URL. + * + * @example + * ```js + * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg + * ``` + * + * @return {string} Displayed URL. + */ +function filterURLForDisplay(url) { + // Remove protocol and www prefixes. + var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. + + if (filteredURL.match(/^[^\/]+\/$/)) { + return filteredURL.replace('/', ''); + } + + return filteredURL; +} + +// EXTERNAL MODULE: external {"this":"lodash"} +var external_this_lodash_ = __webpack_require__(2); + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/clean-for-slug.js +/** + * External dependencies + */ + +/** + * Performs some basic cleanup of a string for use as a post slug. + * + * This replicates some of what `sanitize_title()` does in WordPress core, but + * is only designed to approximate what the slug will be. + * + * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin + * letters. Removes combining diacritical marks. Converts whitespace, periods, + * and forward slashes to hyphens. Removes any remaining non-word characters + * except hyphens. Converts remaining string to lowercase. It does not account + * for octets, HTML entities, or other encoded characters. + * + * @param {string} string Title or slug to be processed. + * + * @return {string} Processed string. + */ + +function cleanForSlug(string) { + if (!string) { + return ''; + } + + return Object(external_this_lodash_["trim"])(Object(external_this_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-'); +} + +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/index.js -var stringify = __webpack_require__(355); -var parse = __webpack_require__(356); -var formats = __webpack_require__(202); + + + + + + + + + -module.exports = { - formats: formats, - parse: parse, - stringify: stringify -}; + + + + + + + + + + /***/ })