Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: url.js
var _iterator = _createForOfIteratorHelper(valuePairs),
[500] Fix | Delete
_step;
[501] Fix | Delete
[502] Fix | Delete
try {
[503] Fix | Delete
for (_iterator.s(); !(_step = _iterator.n()).done;) {
[504] Fix | Delete
var _step$value = Object(slicedToArray["a" /* default */])(_step.value, 2),
[505] Fix | Delete
member = _step$value[0],
[506] Fix | Delete
memberValue = _step$value[1];
[507] Fix | Delete
[508] Fix | Delete
stack.unshift(["".concat(key, "[").concat(member, "]"), memberValue]);
[509] Fix | Delete
}
[510] Fix | Delete
} catch (err) {
[511] Fix | Delete
_iterator.e(err);
[512] Fix | Delete
} finally {
[513] Fix | Delete
_iterator.f();
[514] Fix | Delete
}
[515] Fix | Delete
} else if (value !== undefined) {
[516] Fix | Delete
// Null is treated as special case, equivalent to empty string.
[517] Fix | Delete
if (value === null) {
[518] Fix | Delete
value = '';
[519] Fix | Delete
}
[520] Fix | Delete
[521] Fix | Delete
string += '&' + [key, value].map(encodeURIComponent).join('=');
[522] Fix | Delete
}
[523] Fix | Delete
} // Loop will concatenate with leading `&`, but it's only expected for all
[524] Fix | Delete
// but the first query parameter. This strips the leading `&`, while still
[525] Fix | Delete
// accounting for the case that the string may in-fact be empty.
[526] Fix | Delete
[527] Fix | Delete
[528] Fix | Delete
return string.substr(1);
[529] Fix | Delete
}
[530] Fix | Delete
[531] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-query-string.js
[532] Fix | Delete
/**
[533] Fix | Delete
* Checks for invalid characters within the provided query string.
[534] Fix | Delete
*
[535] Fix | Delete
* @param {string} queryString The query string.
[536] Fix | Delete
*
[537] Fix | Delete
* @example
[538] Fix | Delete
* ```js
[539] Fix | Delete
* const isValid = isValidQueryString( 'query=true&another=false' ); // true
[540] Fix | Delete
* const isNotValid = isValidQueryString( 'query=true?another=false' ); // false
[541] Fix | Delete
* ```
[542] Fix | Delete
*
[543] Fix | Delete
* @return {boolean} True if the argument contains a valid query string.
[544] Fix | Delete
*/
[545] Fix | Delete
function isValidQueryString(queryString) {
[546] Fix | Delete
if (!queryString) {
[547] Fix | Delete
return false;
[548] Fix | Delete
}
[549] Fix | Delete
[550] Fix | Delete
return /^[^\s#?\/]+$/.test(queryString);
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path-and-query-string.js
[554] Fix | Delete
/**
[555] Fix | Delete
* Internal dependencies
[556] Fix | Delete
*/
[557] Fix | Delete
[558] Fix | Delete
/**
[559] Fix | Delete
* Returns the path part and query string part of the URL.
[560] Fix | Delete
*
[561] Fix | Delete
* @param {string} url The full URL.
[562] Fix | Delete
*
[563] Fix | Delete
* @example
[564] Fix | Delete
* ```js
[565] Fix | Delete
* const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
[566] Fix | Delete
* const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
[567] Fix | Delete
* ```
[568] Fix | Delete
*
[569] Fix | Delete
* @return {string} The path part and query string part of the URL.
[570] Fix | Delete
*/
[571] Fix | Delete
[572] Fix | Delete
function getPathAndQueryString(url) {
[573] Fix | Delete
var path = getPath(url);
[574] Fix | Delete
var queryString = getQueryString(url);
[575] Fix | Delete
var value = '/';
[576] Fix | Delete
if (path) value += path;
[577] Fix | Delete
if (queryString) value += "?".concat(queryString);
[578] Fix | Delete
return value;
[579] Fix | Delete
}
[580] Fix | Delete
[581] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-fragment.js
[582] Fix | Delete
/**
[583] Fix | Delete
* Returns the fragment part of the URL.
[584] Fix | Delete
*
[585] Fix | Delete
* @param {string} url The full URL
[586] Fix | Delete
*
[587] Fix | Delete
* @example
[588] Fix | Delete
* ```js
[589] Fix | Delete
* const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
[590] Fix | Delete
* const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
[591] Fix | Delete
* ```
[592] Fix | Delete
*
[593] Fix | Delete
* @return {string|void} The fragment part of the URL.
[594] Fix | Delete
*/
[595] Fix | Delete
function getFragment(url) {
[596] Fix | Delete
var matches = /^\S+?(#[^\s\?]*)/.exec(url);
[597] Fix | Delete
[598] Fix | Delete
if (matches) {
[599] Fix | Delete
return matches[1];
[600] Fix | Delete
}
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-fragment.js
[604] Fix | Delete
/**
[605] Fix | Delete
* Checks for invalid characters within the provided fragment.
[606] Fix | Delete
*
[607] Fix | Delete
* @param {string} fragment The url fragment.
[608] Fix | Delete
*
[609] Fix | Delete
* @example
[610] Fix | Delete
* ```js
[611] Fix | Delete
* const isValid = isValidFragment( '#valid-fragment' ); // true
[612] Fix | Delete
* const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
[613] Fix | Delete
* ```
[614] Fix | Delete
*
[615] Fix | Delete
* @return {boolean} True if the argument contains a valid fragment.
[616] Fix | Delete
*/
[617] Fix | Delete
function isValidFragment(fragment) {
[618] Fix | Delete
if (!fragment) {
[619] Fix | Delete
return false;
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
return /^#[^\s#?\/]*$/.test(fragment);
[623] Fix | Delete
}
[624] Fix | Delete
[625] Fix | Delete
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
[626] Fix | Delete
var defineProperty = __webpack_require__("rePB");
[627] Fix | Delete
[628] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-args.js
[629] Fix | Delete
[630] Fix | Delete
[631] Fix | Delete
[632] Fix | Delete
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
[633] Fix | Delete
[634] Fix | Delete
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
[635] Fix | Delete
[636] Fix | Delete
/**
[637] Fix | Delete
* Internal dependencies
[638] Fix | Delete
*/
[639] Fix | Delete
[640] Fix | Delete
/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */
[641] Fix | Delete
[642] Fix | Delete
/**
[643] Fix | Delete
* @typedef {Record<string,QueryArgParsed>} QueryArgs
[644] Fix | Delete
*/
[645] Fix | Delete
[646] Fix | Delete
/**
[647] Fix | Delete
* Sets a value in object deeply by a given array of path segments. Mutates the
[648] Fix | Delete
* object reference.
[649] Fix | Delete
*
[650] Fix | Delete
* @param {Record<string,*>} object Object in which to assign.
[651] Fix | Delete
* @param {string[]} path Path segment at which to set value.
[652] Fix | Delete
* @param {*} value Value to set.
[653] Fix | Delete
*/
[654] Fix | Delete
[655] Fix | Delete
function setPath(object, path, value) {
[656] Fix | Delete
var length = path.length;
[657] Fix | Delete
var lastIndex = length - 1;
[658] Fix | Delete
[659] Fix | Delete
for (var i = 0; i < length; i++) {
[660] Fix | Delete
var key = path[i];
[661] Fix | Delete
[662] Fix | Delete
if (!key && Array.isArray(object)) {
[663] Fix | Delete
// If key is empty string and next value is array, derive key from
[664] Fix | Delete
// the current length of the array.
[665] Fix | Delete
key = object.length.toString();
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be
[669] Fix | Delete
// created as an array. Otherwise, it will be created as an object.
[670] Fix | Delete
[671] Fix | Delete
var isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
[672] Fix | Delete
object[key] = i === lastIndex ? // If at end of path, assign the intended value.
[673] Fix | Delete
value : // Otherwise, advance to the next object in the path, creating
[674] Fix | Delete
// it if it does not yet exist.
[675] Fix | Delete
object[key] || (isNextKeyArrayIndex ? [] : {});
[676] Fix | Delete
[677] Fix | Delete
if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
[678] Fix | Delete
// If we current key is non-numeric, but the next value is an
[679] Fix | Delete
// array, coerce the value to an object.
[680] Fix | Delete
object[key] = _objectSpread({}, object[key]);
[681] Fix | Delete
} // Update working reference object to the next in the path.
[682] Fix | Delete
[683] Fix | Delete
[684] Fix | Delete
object = object[key];
[685] Fix | Delete
}
[686] Fix | Delete
}
[687] Fix | Delete
/**
[688] Fix | Delete
* Returns an object of query arguments of the given URL. If the given URL is
[689] Fix | Delete
* invalid or has no querystring, an empty object is returned.
[690] Fix | Delete
*
[691] Fix | Delete
* @param {string} url URL.
[692] Fix | Delete
*
[693] Fix | Delete
* @example
[694] Fix | Delete
* ```js
[695] Fix | Delete
* const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );
[696] Fix | Delete
* // { "foo": "bar", "bar": "baz" }
[697] Fix | Delete
* ```
[698] Fix | Delete
*
[699] Fix | Delete
* @return {QueryArgs} Query args object.
[700] Fix | Delete
*/
[701] Fix | Delete
[702] Fix | Delete
[703] Fix | Delete
function getQueryArgs(url) {
[704] Fix | Delete
return (getQueryString(url) || ''). // Normalize space encoding, accounting for PHP URL encoding
[705] Fix | Delete
// corresponding to `application/x-www-form-urlencoded`.
[706] Fix | Delete
//
[707] Fix | Delete
// See: https://tools.ietf.org/html/rfc1866#section-8.2.1
[708] Fix | Delete
replace(/\+/g, '%20').split('&').reduce(function (accumulator, keyValue) {
[709] Fix | Delete
var _keyValue$split$filte = keyValue.split('=') // Filtering avoids decoding as `undefined` for value, where
[710] Fix | Delete
// default is restored in destructuring assignment.
[711] Fix | Delete
.filter(Boolean).map(decodeURIComponent),
[712] Fix | Delete
_keyValue$split$filte2 = Object(slicedToArray["a" /* default */])(_keyValue$split$filte, 2),
[713] Fix | Delete
key = _keyValue$split$filte2[0],
[714] Fix | Delete
_keyValue$split$filte3 = _keyValue$split$filte2[1],
[715] Fix | Delete
value = _keyValue$split$filte3 === void 0 ? '' : _keyValue$split$filte3;
[716] Fix | Delete
[717] Fix | Delete
if (key) {
[718] Fix | Delete
var segments = key.replace(/\]/g, '').split('[');
[719] Fix | Delete
setPath(accumulator, segments, value);
[720] Fix | Delete
}
[721] Fix | Delete
[722] Fix | Delete
return accumulator;
[723] Fix | Delete
}, Object.create(null));
[724] Fix | Delete
}
[725] Fix | Delete
[726] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js
[727] Fix | Delete
/**
[728] Fix | Delete
* Internal dependencies
[729] Fix | Delete
*/
[730] Fix | Delete
[731] Fix | Delete
[732] Fix | Delete
/**
[733] Fix | Delete
* Appends arguments as querystring to the provided URL. If the URL already
[734] Fix | Delete
* includes query arguments, the arguments are merged with (and take precedent
[735] Fix | Delete
* over) the existing set.
[736] Fix | Delete
*
[737] Fix | Delete
* @param {string} [url=''] URL to which arguments should be appended. If omitted,
[738] Fix | Delete
* only the resulting querystring is returned.
[739] Fix | Delete
* @param {Object} [args] Query arguments to apply to URL.
[740] Fix | Delete
*
[741] Fix | Delete
* @example
[742] Fix | Delete
* ```js
[743] Fix | Delete
* const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
[744] Fix | Delete
* ```
[745] Fix | Delete
*
[746] Fix | Delete
* @return {string} URL with arguments applied.
[747] Fix | Delete
*/
[748] Fix | Delete
[749] Fix | Delete
function addQueryArgs() {
[750] Fix | Delete
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
[751] Fix | Delete
var args = arguments.length > 1 ? arguments[1] : undefined;
[752] Fix | Delete
[753] Fix | Delete
// If no arguments are to be appended, return original URL.
[754] Fix | Delete
if (!args || !Object.keys(args).length) {
[755] Fix | Delete
return url;
[756] Fix | Delete
}
[757] Fix | Delete
[758] Fix | Delete
var baseUrl = url; // Determine whether URL already had query arguments.
[759] Fix | Delete
[760] Fix | Delete
var queryStringIndex = url.indexOf('?');
[761] Fix | Delete
[762] Fix | Delete
if (queryStringIndex !== -1) {
[763] Fix | Delete
// Merge into existing query arguments.
[764] Fix | Delete
args = Object.assign(getQueryArgs(url), args); // Change working base URL to omit previous query arguments.
[765] Fix | Delete
[766] Fix | Delete
baseUrl = baseUrl.substr(0, queryStringIndex);
[767] Fix | Delete
}
[768] Fix | Delete
[769] Fix | Delete
return baseUrl + '?' + buildQueryString(args);
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js
[773] Fix | Delete
/**
[774] Fix | Delete
* Internal dependencies
[775] Fix | Delete
*/
[776] Fix | Delete
[777] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[778] Fix | Delete
[779] Fix | Delete
/**
[780] Fix | Delete
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
[781] Fix | Delete
*/
[782] Fix | Delete
[783] Fix | Delete
/* eslint-enable */
[784] Fix | Delete
[785] Fix | Delete
/**
[786] Fix | Delete
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
[787] Fix | Delete
*/
[788] Fix | Delete
[789] Fix | Delete
/**
[790] Fix | Delete
* Returns a single query argument of the url
[791] Fix | Delete
*
[792] Fix | Delete
* @param {string} url URL.
[793] Fix | Delete
* @param {string} arg Query arg name.
[794] Fix | Delete
*
[795] Fix | Delete
* @example
[796] Fix | Delete
* ```js
[797] Fix | Delete
* const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar
[798] Fix | Delete
* ```
[799] Fix | Delete
*
[800] Fix | Delete
* @return {QueryArgParsed|void} Query arg value.
[801] Fix | Delete
*/
[802] Fix | Delete
[803] Fix | Delete
function getQueryArg(url, arg) {
[804] Fix | Delete
return getQueryArgs(url)[arg];
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js
[808] Fix | Delete
/**
[809] Fix | Delete
* Internal dependencies
[810] Fix | Delete
*/
[811] Fix | Delete
[812] Fix | Delete
/**
[813] Fix | Delete
* Determines whether the URL contains a given query arg.
[814] Fix | Delete
*
[815] Fix | Delete
* @param {string} url URL.
[816] Fix | Delete
* @param {string} arg Query arg name.
[817] Fix | Delete
*
[818] Fix | Delete
* @example
[819] Fix | Delete
* ```js
[820] Fix | Delete
* const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
[821] Fix | Delete
* ```
[822] Fix | Delete
*
[823] Fix | Delete
* @return {boolean} Whether or not the URL contains the query arg.
[824] Fix | Delete
*/
[825] Fix | Delete
[826] Fix | Delete
function hasQueryArg(url, arg) {
[827] Fix | Delete
return getQueryArg(url, arg) !== undefined;
[828] Fix | Delete
}
[829] Fix | Delete
[830] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js
[831] Fix | Delete
/**
[832] Fix | Delete
* Internal dependencies
[833] Fix | Delete
*/
[834] Fix | Delete
[835] Fix | Delete
[836] Fix | Delete
/**
[837] Fix | Delete
* Removes arguments from the query string of the url
[838] Fix | Delete
*
[839] Fix | Delete
* @param {string} url URL.
[840] Fix | Delete
* @param {...string} args Query Args.
[841] Fix | Delete
*
[842] Fix | Delete
* @example
[843] Fix | Delete
* ```js
[844] Fix | Delete
* const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
[845] Fix | Delete
* ```
[846] Fix | Delete
*
[847] Fix | Delete
* @return {string} Updated URL.
[848] Fix | Delete
*/
[849] Fix | Delete
[850] Fix | Delete
function removeQueryArgs(url) {
[851] Fix | Delete
var queryStringIndex = url.indexOf('?');
[852] Fix | Delete
[853] Fix | Delete
if (queryStringIndex === -1) {
[854] Fix | Delete
return url;
[855] Fix | Delete
}
[856] Fix | Delete
[857] Fix | Delete
var query = getQueryArgs(url);
[858] Fix | Delete
var baseURL = url.substr(0, queryStringIndex);
[859] Fix | Delete
[860] Fix | Delete
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
[861] Fix | Delete
args[_key - 1] = arguments[_key];
[862] Fix | Delete
}
[863] Fix | Delete
[864] Fix | Delete
args.forEach(function (arg) {
[865] Fix | Delete
return delete query[arg];
[866] Fix | Delete
});
[867] Fix | Delete
var queryString = buildQueryString(query);
[868] Fix | Delete
return queryString ? baseURL + '?' + queryString : baseURL;
[869] Fix | Delete
}
[870] Fix | Delete
[871] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js
[872] Fix | Delete
/**
[873] Fix | Delete
* Internal dependencies
[874] Fix | Delete
*/
[875] Fix | Delete
[876] Fix | Delete
var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
[877] Fix | Delete
/**
[878] Fix | Delete
* Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
[879] Fix | Delete
*
[880] Fix | Delete
* @param {string} url The URL to test.
[881] Fix | Delete
*
[882] Fix | Delete
* @example
[883] Fix | Delete
* ```js
[884] Fix | Delete
* const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org
[885] Fix | Delete
* ```
[886] Fix | Delete
*
[887] Fix | Delete
* @return {string} The updated URL.
[888] Fix | Delete
*/
[889] Fix | Delete
[890] Fix | Delete
function prependHTTP(url) {
[891] Fix | Delete
if (!url) {
[892] Fix | Delete
return url;
[893] Fix | Delete
}
[894] Fix | Delete
[895] Fix | Delete
url = url.trim();
[896] Fix | Delete
[897] Fix | Delete
if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
[898] Fix | Delete
return 'http://' + url;
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
return url;
[902] Fix | Delete
}
[903] Fix | Delete
[904] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri.js
[905] Fix | Delete
/**
[906] Fix | Delete
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
[907] Fix | Delete
* `decodeURI` throws an error.
[908] Fix | Delete
*
[909] Fix | Delete
* @param {string} uri URI to decode.
[910] Fix | Delete
*
[911] Fix | Delete
* @example
[912] Fix | Delete
* ```js
[913] Fix | Delete
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
[914] Fix | Delete
* ```
[915] Fix | Delete
*
[916] Fix | Delete
* @return {string} Decoded URI if possible.
[917] Fix | Delete
*/
[918] Fix | Delete
function safeDecodeURI(uri) {
[919] Fix | Delete
try {
[920] Fix | Delete
return decodeURI(uri);
[921] Fix | Delete
} catch (uriError) {
[922] Fix | Delete
return uri;
[923] Fix | Delete
}
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri-component.js
[927] Fix | Delete
/**
[928] Fix | Delete
* Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
[929] Fix | Delete
* `decodeURIComponent` throws an error.
[930] Fix | Delete
*
[931] Fix | Delete
* @param {string} uriComponent URI component to decode.
[932] Fix | Delete
*
[933] Fix | Delete
* @return {string} Decoded URI component if possible.
[934] Fix | Delete
*/
[935] Fix | Delete
function safeDecodeURIComponent(uriComponent) {
[936] Fix | Delete
try {
[937] Fix | Delete
return decodeURIComponent(uriComponent);
[938] Fix | Delete
} catch (uriComponentError) {
[939] Fix | Delete
return uriComponent;
[940] Fix | Delete
}
[941] Fix | Delete
}
[942] Fix | Delete
[943] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/filter-url-for-display.js
[944] Fix | Delete
/**
[945] Fix | Delete
* Returns a URL for display.
[946] Fix | Delete
*
[947] Fix | Delete
* @param {string} url Original URL.
[948] Fix | Delete
* @param {number|null} maxLength URL length.
[949] Fix | Delete
*
[950] Fix | Delete
* @example
[951] Fix | Delete
* ```js
[952] Fix | Delete
* const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
[953] Fix | Delete
* const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
[954] Fix | Delete
* ```
[955] Fix | Delete
*
[956] Fix | Delete
* @return {string} Displayed URL.
[957] Fix | Delete
*/
[958] Fix | Delete
function filterURLForDisplay(url) {
[959] Fix | Delete
var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
[960] Fix | Delete
// Remove protocol and www prefixes.
[961] Fix | Delete
var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
[962] Fix | Delete
[963] Fix | Delete
if (filteredURL.match(/^[^\/]+\/$/)) {
[964] Fix | Delete
filteredURL = filteredURL.replace('/', '');
[965] Fix | Delete
}
[966] Fix | Delete
[967] Fix | Delete
var mediaRegexp = /([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/;
[968] Fix | Delete
[969] Fix | Delete
if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(mediaRegexp)) {
[970] Fix | Delete
return filteredURL;
[971] Fix | Delete
} // If the file is not greater than max length, return last portion of URL.
[972] Fix | Delete
[973] Fix | Delete
[974] Fix | Delete
filteredURL = filteredURL.split('?')[0];
[975] Fix | Delete
var urlPieces = filteredURL.split('/');
[976] Fix | Delete
var file = urlPieces[urlPieces.length - 1];
[977] Fix | Delete
[978] Fix | Delete
if (file.length <= maxLength) {
[979] Fix | Delete
return '…' + filteredURL.slice(-maxLength);
[980] Fix | Delete
} // If the file is greater than max length, truncate the file.
[981] Fix | Delete
[982] Fix | Delete
[983] Fix | Delete
var index = file.lastIndexOf('.');
[984] Fix | Delete
var _ref = [file.slice(0, index), file.slice(index + 1)],
[985] Fix | Delete
fileName = _ref[0],
[986] Fix | Delete
extension = _ref[1];
[987] Fix | Delete
var truncatedFile = fileName.slice(-3) + '.' + extension;
[988] Fix | Delete
return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile;
[989] Fix | Delete
}
[990] Fix | Delete
[991] Fix | Delete
// EXTERNAL MODULE: external "lodash"
[992] Fix | Delete
var external_lodash_ = __webpack_require__("YLtl");
[993] Fix | Delete
[994] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/clean-for-slug.js
[995] Fix | Delete
/**
[996] Fix | Delete
* External dependencies
[997] Fix | Delete
*/
[998] Fix | Delete
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function