diff -r 34716fd837a4 -r be944660c56a wp/wp-includes/js/dist/url.js --- a/wp/wp-includes/js/dist/url.js Tue Dec 15 15:52:01 2020 +0100 +++ b/wp/wp-includes/js/dist/url.js Wed Sep 21 18:19:35 2022 +0200 @@ -82,829 +82,19 @@ /******/ /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 444); +/******/ return __webpack_require__(__webpack_require__.s = "lbya"); /******/ }) /************************************************************************/ /******/ ({ -/***/ 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: +/***/ "YLtl": /***/ (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 = []; - for (var i = 0; i < 256; ++i) { - array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); - } - - return array; -}()); - -var compactQueue = function compactQueue(queue) { - while (queue.length > 1) { - var item = queue.pop(); - var obj = item.obj[item.prop]; - - if (isArray(obj)) { - var compacted = []; - - for (var j = 0; j < obj.length; ++j) { - if (typeof obj[j] !== 'undefined') { - compacted.push(obj[j]); - } - } - - item.obj[item.prop] = compacted; - } - } -}; - -var arrayToObject = function arrayToObject(source, options) { - var obj = options && options.plainObjects ? Object.create(null) : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== 'undefined') { - obj[i] = source[i]; - } - } - - return obj; -}; - -var merge = function merge(target, source, options) { - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (isArray(target)) { - target.push(source); - } else if (target && typeof target === 'object') { - if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { - target[source] = true; - } - } else { - return [target, source]; - } - - return target; - } - - if (!target || typeof target !== 'object') { - return [target].concat(source); - } - - var mergeTarget = target; - if (isArray(target) && !isArray(source)) { - mergeTarget = arrayToObject(target, options); - } - - if (isArray(target) && isArray(source)) { - source.forEach(function (item, i) { - if (has.call(target, i)) { - var targetItem = target[i]; - if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { - target[i] = merge(targetItem, item, options); - } else { - target.push(item); - } - } else { - target[i] = item; - } - }); - return target; - } - - return Object.keys(source).reduce(function (acc, key) { - var value = source[key]; - - if (has.call(acc, key)) { - acc[key] = merge(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); -}; - -var assign = function assignSingleSource(target, source) { - return Object.keys(source).reduce(function (acc, key) { - acc[key] = source[key]; - return acc; - }, target); -}; - -var decode = function (str, decoder, charset) { - var strWithoutPlus = str.replace(/\+/g, ' '); - if (charset === 'iso-8859-1') { - // unescape never throws, no try...catch needed: - return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); - } - // utf-8 - try { - return decodeURIComponent(strWithoutPlus); - } catch (e) { - return strWithoutPlus; - } -}; - -var encode = function encode(str, defaultEncoder, charset) { - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - var string = typeof str === 'string' ? str : String(str); - - if (charset === 'iso-8859-1') { - return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { - return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; - }); - } - - var out = ''; - for (var i = 0; i < string.length; ++i) { - var c = string.charCodeAt(i); - - if ( - c === 0x2D // - - || c === 0x2E // . - || c === 0x5F // _ - || c === 0x7E // ~ - || (c >= 0x30 && c <= 0x39) // 0-9 - || (c >= 0x41 && c <= 0x5A) // a-z - || (c >= 0x61 && c <= 0x7A) // A-Z - ) { - out += string.charAt(i); - continue; - } - - if (c < 0x80) { - out = out + hexTable[c]; - continue; - } - - if (c < 0x800) { - out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - i += 1; - c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += hexTable[0xF0 | (c >> 18)] - + hexTable[0x80 | ((c >> 12) & 0x3F)] - + hexTable[0x80 | ((c >> 6) & 0x3F)] - + hexTable[0x80 | (c & 0x3F)]; - } - - return out; -}; - -var compact = function compact(value) { - var queue = [{ obj: { o: value }, prop: 'o' }]; - var refs = []; - - for (var i = 0; i < queue.length; ++i) { - var item = queue[i]; - var obj = item.obj[item.prop]; - - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - var val = obj[key]; - if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { - queue.push({ obj: obj, prop: key }); - refs.push(val); - } - } - } - - compactQueue(queue); - - return value; -}; - -var isRegExp = function isRegExp(obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; -}; - -var isBuffer = function isBuffer(obj) { - if (!obj || typeof obj !== 'object') { - return false; - } - - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); -}; - -var combine = function combine(a, b) { - return [].concat(a, b); -}; - -module.exports = { - arrayToObject: arrayToObject, - assign: assign, - combine: combine, - compact: compact, - decode: decode, - encode: encode, - isBuffer: isBuffer, - isRegExp: isRegExp, - merge: merge -}; - - -/***/ }), - -/***/ 259: -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var replace = String.prototype.replace; -var percentTwenties = /%20/g; - -module.exports = { - 'default': 'RFC3986', - formatters: { - RFC1738: function (value) { - return replace.call(value, percentTwenties, '+'); - }, - RFC3986: function (value) { - return value; - } - }, - RFC1738: 'RFC1738', - RFC3986: 'RFC3986' -}; - +(function() { module.exports = window["lodash"]; }()); /***/ }), -/***/ 433: -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -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 + ']'; - }, - repeat: function repeat(prefix) { // eslint-disable-line func-name-matching - return prefix; - } -}; - -var isArray = Array.isArray; -var push = Array.prototype.push; -var pushToArray = function (arr, valueOrArray) { - push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); -}; - -var toISO = Date.prototype.toISOString; - -var defaults = { - addQueryPrefix: false, - allowDots: false, - charset: 'utf-8', - charsetSentinel: false, - delimiter: '&', - 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 - return toISO.call(date); - }, - skipNulls: false, - strictNullHandling: false -}; - -var stringify = function stringify( // eslint-disable-line func-name-matching - object, - prefix, - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - formatter, - encodeValuesOnly, - charset -) { - var obj = object; - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = serializeDate(obj); - } else if (generateArrayPrefix === 'comma' && isArray(obj)) { - obj = obj.join(','); - } - - if (obj === null) { - if (strictNullHandling) { - return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix; - } - - obj = ''; - } - - if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { - if (encoder) { - var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset); - return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))]; - } - return [formatter(prefix) + '=' + formatter(String(obj))]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys; - if (isArray(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (skipNulls && obj[key] === null) { - continue; - } - - if (isArray(obj)) { - pushToArray(values, stringify( - obj[key], - typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix, - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - formatter, - encodeValuesOnly, - charset - )); - } else { - pushToArray(values, stringify( - obj[key], - prefix + (allowDots ? '.' + key : '[' + key + ']'), - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - formatter, - encodeValuesOnly, - charset - )); - } - } - - return values; -}; - -var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { - if (!opts) { - return defaults; - } - - if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - - 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; - } - - 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 (isArray(options.filter)) { - filter = options.filter; - objKeys = filter; - } - - var keys = []; - - if (typeof obj !== 'object' || obj === null) { - return ''; - } - - var arrayFormat; - if (opts && opts.arrayFormat in arrayPrefixGenerators) { - arrayFormat = opts.arrayFormat; - } else if (opts && 'indices' in opts) { - arrayFormat = opts.indices ? 'indices' : 'repeat'; - } else { - arrayFormat = 'indices'; - } - - var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - - if (options.sort) { - objKeys.sort(options.sort); - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (options.skipNulls && obj[key] === null) { - continue; - } - pushToArray(keys, stringify( - obj[key], - key, - generateArrayPrefix, - 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(options.delimiter); - var prefix = options.addQueryPrefix === true ? '?' : ''; - - if (options.charsetSentinel) { - if (options.charset === 'iso-8859-1') { - // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark - prefix += 'utf8=%26%2310003%3B&'; - } else { - // encodeURIComponent('✓') - prefix += 'utf8=%E2%9C%93&'; - } - } - - return joined.length > 0 ? prefix + joined : ''; -}; - - -/***/ }), - -/***/ 434: -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var utils = __webpack_require__(258); - -var has = Object.prototype.hasOwnProperty; - -var defaults = { - allowDots: false, - allowPrototypes: false, - arrayLimit: 20, - charset: 'utf-8', - charsetSentinel: false, - comma: false, - decoder: utils.decode, - delimiter: '&', - depth: 5, - ignoreQueryPrefix: false, - interpretNumericEntities: false, - parameterLimit: 1000, - parseArrays: true, - plainObjects: false, - strictNullHandling: false -}; - -var interpretNumericEntities = function (str) { - return str.replace(/&#(\d+);/g, function ($0, numberStr) { - return String.fromCharCode(parseInt(numberStr, 10)); - }); -}; - -// This is what browsers will submit when the ✓ character occurs in an -// application/x-www-form-urlencoded body and the encoding of the page containing -// the form is iso-8859-1, or when the submitted form has an accept-charset -// attribute of iso-8859-1. Presumably also with other charsets that do not contain -// the ✓ character, such as us-ascii. -var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') - -// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. -var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') - -var parseValues = function parseQueryStringValues(str, options) { - var obj = {}; - var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; - var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; - var parts = cleanStr.split(options.delimiter, limit); - var skipIndex = -1; // Keep track of where the utf8 sentinel was found - var i; - - var charset = options.charset; - if (options.charsetSentinel) { - for (i = 0; i < parts.length; ++i) { - if (parts[i].indexOf('utf8=') === 0) { - if (parts[i] === charsetSentinel) { - charset = 'utf-8'; - } else if (parts[i] === isoSentinel) { - charset = 'iso-8859-1'; - } - skipIndex = i; - i = parts.length; // The eslint settings do not allow break; - } - } - } - - for (i = 0; i < parts.length; ++i) { - if (i === skipIndex) { - continue; - } - var part = parts[i]; - - var bracketEqualsPos = part.indexOf(']='); - var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; - - var key, val; - if (pos === -1) { - key = options.decoder(part, defaults.decoder, charset); - val = options.strictNullHandling ? null : ''; - } else { - key = options.decoder(part.slice(0, pos), defaults.decoder, charset); - val = options.decoder(part.slice(pos + 1), defaults.decoder, charset); - } - - 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 { - obj[key] = val; - } - } - - return obj; -}; - -var parseObject = function (chain, val, options) { - var leaf = val; - - for (var i = chain.length - 1; i >= 0; --i) { - var obj; - var root = chain[i]; - - if (root === '[]' && options.parseArrays) { - obj = [].concat(leaf); - } else { - obj = options.plainObjects ? Object.create(null) : {}; - var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; - var index = parseInt(cleanRoot, 10); - if (!options.parseArrays && cleanRoot === '') { - obj = { 0: leaf }; - } else if ( - !isNaN(index) - && root !== cleanRoot - && String(index) === cleanRoot - && index >= 0 - && (options.parseArrays && index <= options.arrayLimit) - ) { - obj = []; - obj[index] = leaf; - } else { - obj[cleanRoot] = leaf; - } - } - - leaf = obj; - } - - return leaf; -}; - -var parseKeys = function parseQueryStringKeys(givenKey, val, options) { - if (!givenKey) { - return; - } - - // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; - - // The regex chunks - - var brackets = /(\[[^[\]]*])/; - var child = /(\[[^[\]]*])/g; - - // Get the parent - - var segment = brackets.exec(key); - var parent = segment ? key.slice(0, segment.index) : key; - - // Stash the parent if it exists - - var keys = []; - if (parent) { - // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties - if (!options.plainObjects && has.call(Object.prototype, parent)) { - if (!options.allowPrototypes) { - return; - } - } - - keys.push(parent); - } - - // Loop through children appending to the array until we hit depth - - var i = 0; - while ((segment = child.exec(key)) !== null && i < options.depth) { - i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { - if (!options.allowPrototypes) { - return; - } - } - keys.push(segment[1]); - } - - // If there's a remainder, just add whatever is left - - if (segment) { - keys.push('[' + key.slice(segment.index) + ']'); - } - - return parseObject(keys, val, options); -}; - -var normalizeParseOptions = function normalizeParseOptions(opts) { - if (!opts) { - return defaults; - } - - if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { - throw new TypeError('Decoder has to be a function.'); - } - - 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'); - } - 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) : {}; - } - - var tempObj = typeof str === 'string' ? parseValues(str, options) : str; - var obj = options.plainObjects ? Object.create(null) : {}; - - // Iterate over the keys and setup the new object - - var keys = Object.keys(tempObj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - var newObj = parseKeys(key, tempObj[key], options); - obj = utils.merge(obj, newObj, options); - } - - return utils.compact(obj); -}; - - -/***/ }), - -/***/ 444: +/***/ "lbya": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -921,12 +111,14 @@ __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__, "buildQueryString", function() { return /* reexport */ buildQueryString; }); __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__, "getQueryArgs", function() { return /* reexport */ getQueryArgs; }); __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; }); @@ -957,13 +149,13 @@ try { new URL(url); return true; - } catch (_unused) { + } catch { 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; +const 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. * @@ -996,7 +188,7 @@ * @return {string|void} The protocol part of the URL. */ function getProtocol(url) { - var matches = /^([^\s:]+:)/.exec(url); + const matches = /^([^\s:]+:)/.exec(url); if (matches) { return matches[1]; @@ -1040,7 +232,7 @@ * @return {string|void} The authority part of the URL. */ function getAuthority(url) { - var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); + const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); if (matches) { return matches[1]; @@ -1084,7 +276,7 @@ * @return {string|void} The path part of the URL. */ function getPath(url) { - var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); + const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); if (matches) { return matches[1]; @@ -1127,10 +319,10 @@ * @return {string|void} The query string part of the URL. */ function getQueryString(url) { - var query; + let query; try { - query = new URL(url).search.substring(1); + query = new URL(url, 'http://example.com').search.substring(1); } catch (error) {} if (query) { @@ -1138,6 +330,66 @@ } } +// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/build-query-string.js +/** + * Generates URL-encoded query string using input query data. + * + * It is intended to behave equivalent as PHP's `http_build_query`, configured + * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`). + * + * @example + * ```js + * const queryString = buildQueryString( { + * simple: 'is ok', + * arrays: [ 'are', 'fine', 'too' ], + * objects: { + * evenNested: { + * ok: 'yes', + * }, + * }, + * } ); + * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes" + * ``` + * + * @param {Record} data Data to encode. + * + * @return {string} Query string. + */ +function buildQueryString(data) { + let string = ''; + const stack = Object.entries(data); + let pair; + + while (pair = stack.shift()) { + let [key, value] = pair; // Support building deeply nested data, from array or object values. + + const hasNestedData = Array.isArray(value) || value && value.constructor === Object; + + if (hasNestedData) { + // Push array or object values onto the stack as composed of their + // original key and nested index or key, retaining order by a + // combination of Array#reverse and Array#unshift onto the stack. + const valuePairs = Object.entries(value).reverse(); + + for (const [member, memberValue] of valuePairs) { + stack.unshift([`${key}[${member}]`, memberValue]); + } + } else if (value !== undefined) { + // Null is treated as special case, equivalent to empty string. + if (value === null) { + value = ''; + } + + string += '&' + [key, value].map(encodeURIComponent).join('='); + } + } // Loop will concatenate with leading `&`, but it's only expected for all + // but the first query parameter. This strips the leading `&`, while still + // accounting for the case that the string may in-fact be empty. + + + return string.substr(1); +} + // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-query-string.js /** * Checks for invalid characters within the provided query string. @@ -1180,11 +432,11 @@ */ function getPathAndQueryString(url) { - var path = getPath(url); - var queryString = getQueryString(url); - var value = '/'; + const path = getPath(url); + const queryString = getQueryString(url); + let value = '/'; if (path) value += path; - if (queryString) value += "?".concat(queryString); + if (queryString) value += `?${queryString}`; return value; } @@ -1203,7 +455,7 @@ * @return {string|void} The fragment part of the URL. */ function getFragment(url) { - var matches = /^\S+?(#[^\s\?]*)/.exec(url); + const matches = /^\S+?(#[^\s\?]*)/.exec(url); if (matches) { return matches[1]; @@ -1232,14 +484,99 @@ 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/get-query-args.js +/** + * Internal dependencies + */ + +/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */ + +/** + * @typedef {Record} QueryArgs + */ + +/** + * Sets a value in object deeply by a given array of path segments. Mutates the + * object reference. + * + * @param {Record} object Object in which to assign. + * @param {string[]} path Path segment at which to set value. + * @param {*} value Value to set. + */ + +function setPath(object, path, value) { + const length = path.length; + const lastIndex = length - 1; + + for (let i = 0; i < length; i++) { + let key = path[i]; + + if (!key && Array.isArray(object)) { + // If key is empty string and next value is array, derive key from + // the current length of the array. + key = object.length.toString(); + } // If the next key in the path is numeric (or empty string), it will be + // created as an array. Otherwise, it will be created as an object. + + + const isNextKeyArrayIndex = !isNaN(Number(path[i + 1])); + object[key] = i === lastIndex ? // If at end of path, assign the intended value. + value : // Otherwise, advance to the next object in the path, creating + // it if it does not yet exist. + object[key] || (isNextKeyArrayIndex ? [] : {}); + + if (Array.isArray(object[key]) && !isNextKeyArrayIndex) { + // If we current key is non-numeric, but the next value is an + // array, coerce the value to an object. + object[key] = { ...object[key] + }; + } // Update working reference object to the next in the path. + + + object = object[key]; + } +} +/** + * Returns an object of query arguments of the given URL. If the given URL is + * invalid or has no querystring, an empty object is returned. + * + * @param {string} url URL. + * + * @example + * ```js + * const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' ); + * // { "foo": "bar", "bar": "baz" } + * ``` + * + * @return {QueryArgs} Query args object. + */ + + +function getQueryArgs(url) { + return (getQueryString(url) || ''). // Normalize space encoding, accounting for PHP URL encoding + // corresponding to `application/x-www-form-urlencoded`. + // + // See: https://tools.ietf.org/html/rfc1866#section-8.2.1 + replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => { + const [key, value = ''] = keyValue.split('=') // Filtering avoids decoding as `undefined` for value, where + // default is restored in destructuring assignment. + .filter(Boolean).map(decodeURIComponent); + + if (key) { + const segments = key.replace(/\]/g, '').split('['); + setPath(accumulator, segments, value); + } + + return accumulator; + }, {}); +} // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js /** - * External dependencies + * Internal dependencies */ + /** * Appends arguments as querystring to the provided URL. If the URL already * includes query arguments, the arguments are merged with (and take precedent @@ -1257,42 +594,35 @@ * @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; - +function addQueryArgs(url = '', args) { // 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. + let baseUrl = url; // Determine whether URL already had query arguments. - var queryStringIndex = url.indexOf('?'); + const 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. + args = Object.assign(getQueryArgs(url), args); // Change working base URL to omit previous query arguments. baseUrl = baseUrl.substr(0, queryStringIndex); } - return baseUrl + '?' + Object(lib["stringify"])(args); + return baseUrl + '?' + buildQueryString(args); } // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js /** - * External dependencies + * Internal dependencies */ -/* eslint-disable jsdoc/valid-types */ - /** * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject */ -/* eslint-enable */ - /** * @typedef {string|string[]|QueryArgObject} QueryArgParsed */ @@ -1308,13 +638,11 @@ * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar * ``` * - * @return {QueryArgParsed|undefined} Query arg value. + * @return {QueryArgParsed|void} 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]; + return getQueryArgs(url)[arg]; } // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js @@ -1342,9 +670,10 @@ // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js /** - * External dependencies + * Internal dependencies */ + /** * Removes arguments from the query string of the url * @@ -1359,19 +688,18 @@ * @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; +function removeQueryArgs(url, ...args) { + const queryStringIndex = url.indexOf('?'); - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + if (queryStringIndex === -1) { + return url; } - args.forEach(function (arg) { - return delete query[arg]; - }); - return baseUrl + '?' + Object(lib["stringify"])(query); + const query = getQueryArgs(url); + const baseURL = url.substr(0, queryStringIndex); + args.forEach(arg => delete query[arg]); + const queryString = buildQueryString(query); + return queryString ? baseURL + '?' + queryString : baseURL; } // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js @@ -1379,7 +707,7 @@ * Internal dependencies */ -var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; +const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; /** * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. * @@ -1451,27 +779,48 @@ * Returns a URL for display. * * @param {string} url Original URL. + * @param {number|null} maxLength URL length. * * @example * ```js * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg + * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png * ``` * * @return {string} Displayed URL. */ -function filterURLForDisplay(url) { +function filterURLForDisplay(url, maxLength = null) { // Remove protocol and www prefixes. - var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. + let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. if (filteredURL.match(/^[^\/]+\/$/)) { - return filteredURL.replace('/', ''); + filteredURL = filteredURL.replace('/', ''); } - return filteredURL; + const mediaRegexp = /([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/; + + if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(mediaRegexp)) { + return filteredURL; + } // If the file is not greater than max length, return last portion of URL. + + + filteredURL = filteredURL.split('?')[0]; + const urlPieces = filteredURL.split('/'); + const file = urlPieces[urlPieces.length - 1]; + + if (file.length <= maxLength) { + return '…' + filteredURL.slice(-maxLength); + } // If the file is greater than max length, truncate the file. + + + const index = file.lastIndexOf('.'); + const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)]; + const truncatedFile = fileName.slice(-3) + '.' + extension; + return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile; } -// EXTERNAL MODULE: external {"this":"lodash"} -var external_this_lodash_ = __webpack_require__(2); +// EXTERNAL MODULE: external "lodash" +var external_lodash_ = __webpack_require__("YLtl"); // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/clean-for-slug.js /** @@ -1500,7 +849,7 @@ return ''; } - return Object(external_this_lodash_["trim"])(Object(external_this_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-'); + return Object(external_lodash_["trim"])(Object(external_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-'); } // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/index.js @@ -1528,6 +877,8 @@ + + /***/ }) /******/ }); \ No newline at end of file