WordPress/wp-includes/js/dist/url.js

884 lines
26 KiB
JavaScript
Raw Normal View History

this["wp"] = this["wp"] || {}; this["wp"]["url"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "lbya");
/******/ })
/************************************************************************/
/******/ ({
/***/ "YLtl":
/***/ (function(module, exports) {
(function() { module.exports = window["lodash"]; }());
/***/ }),
/***/ "lbya":
2020-01-08 06:57:23 -05:00
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
2020-01-08 06:57:23 -05:00
__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__, "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; });
__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; });
2020-01-08 06:57:23 -05:00
// 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
*
2020-01-08 06:57:23 -05:00
* @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 {
return false;
}
2020-01-08 06:57:23 -05:00
}
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-email.js
const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
2020-01-08 06:57:23 -05:00
/**
* 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) {
const matches = /^([^\s:]+:)/.exec(url);
2020-01-08 06:57:23 -05:00
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) {
const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
2020-01-08 06:57:23 -05:00
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) {
const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
2020-01-08 06:57:23 -05:00
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'
2020-01-08 06:57:23 -05:00
* ```
*
* @return {string|void} The query string part of the URL.
*/
function getQueryString(url) {
let query;
2020-01-08 06:57:23 -05:00
try {
query = new URL(url, 'http://example.com').search.substring(1);
} catch (error) {}
if (query) {
return query;
2020-01-08 06:57:23 -05:00
}
}
// 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<string,*>} 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);
}
2020-01-08 06:57:23 -05:00
// 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;
}
2020-01-08 06:57:23 -05:00
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) {
const path = getPath(url);
const queryString = getQueryString(url);
let value = '/';
if (path) value += path;
if (queryString) value += `?${queryString}`;
return value;
}
2020-01-08 06:57:23 -05:00
// 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) {
const matches = /^\S+?(#[^\s\?]*)/.exec(url);
2020-01-08 06:57:23 -05:00
if (matches) {
return matches[1];
}
}
2020-01-08 06:57:23 -05:00
// 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;
}
2020-01-08 06:57:23 -05:00
return /^#[^\s#?\/]*$/.test(fragment);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-args.js
/**
* Internal dependencies
*/
/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */
/**
* @typedef {Record<string,QueryArgParsed>} QueryArgs
*/
/**
* Sets a value in object deeply by a given array of path segments. Mutates the
* object reference.
*
* @param {Record<string,*>} 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;
}, {});
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js
/**
* Internal dependencies
2020-01-08 06:57:23 -05:00
*/
2020-01-08 06:57:23 -05:00
/**
* 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.
2020-01-08 06:57:23 -05:00
*
* @example
* ```js
* const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
* ```
*
* @return {string} URL with arguments applied.
*/
function addQueryArgs(url = '', args) {
2020-01-08 06:57:23 -05:00
// If no arguments are to be appended, return original URL.
if (!args || !Object.keys(args).length) {
return url;
}
let baseUrl = url; // Determine whether URL already had query arguments.
const queryStringIndex = url.indexOf('?');
2020-01-08 06:57:23 -05:00
if (queryStringIndex !== -1) {
// Merge into existing query arguments.
args = Object.assign(getQueryArgs(url), args); // Change working base URL to omit previous query arguments.
2020-01-08 06:57:23 -05:00
baseUrl = baseUrl.substr(0, queryStringIndex);
}
return baseUrl + '?' + buildQueryString(args);
2020-01-08 06:57:23 -05:00
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js
/**
* Internal dependencies
2020-01-08 06:57:23 -05:00
*/
2020-01-08 06:57:23 -05:00
/**
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
*/
2020-01-08 06:57:23 -05:00
/**
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
*/
2020-01-08 06:57:23 -05:00
/**
* 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|void} Query arg value.
2020-01-08 06:57:23 -05:00
*/
2020-01-08 06:57:23 -05:00
function getQueryArg(url, arg) {
return getQueryArgs(url)[arg];
2020-01-08 06:57:23 -05:00
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js
/**
* Internal dependencies
*/
2020-01-08 06:57:23 -05:00
/**
* 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.
*/
2020-01-08 06:57:23 -05:00
function hasQueryArg(url, arg) {
return getQueryArg(url, arg) !== undefined;
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js
/**
* Internal dependencies
2020-01-08 06:57:23 -05:00
*/
2020-01-08 06:57:23 -05:00
/**
* 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, ...args) {
const queryStringIndex = url.indexOf('?');
if (queryStringIndex === -1) {
return url;
}
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;
2020-01-08 06:57:23 -05:00
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js
/**
* Internal dependencies
*/
const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
2020-01-08 06:57:23 -05:00
/**
* 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.
*/
2020-01-08 06:57:23 -05:00
function prependHTTP(url) {
if (!url) {
return url;
}
2020-01-08 06:57:23 -05:00
url = url.trim();
2020-01-08 06:57:23 -05:00
if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
return 'http://' + url;
}
2020-01-08 06:57:23 -05:00
return url;
}
2020-01-08 06:57:23 -05:00
// 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;
}
}
2020-01-08 06:57:23 -05:00
// 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;
}
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/filter-url-for-display.js
/**
* Returns a URL for display.
*
* @param {string} url Original URL.
* @param {number|null} maxLength URL length.
2020-01-08 06:57:23 -05:00
*
* @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
2020-01-08 06:57:23 -05:00
* ```
*
* @return {string} Displayed URL.
*/
function filterURLForDisplay(url, maxLength = null) {
2020-01-08 06:57:23 -05:00
// Remove protocol and www prefixes.
let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
2020-01-08 06:57:23 -05:00
if (filteredURL.match(/^[^\/]+\/$/)) {
filteredURL = filteredURL.replace('/', '');
2020-01-08 06:57:23 -05:00
}
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;
2020-01-08 06:57:23 -05:00
}
// EXTERNAL MODULE: external "lodash"
var external_lodash_ = __webpack_require__("YLtl");
Block Editor: Update WordPress Packages. The following package versions were changed: @wordpress/a11y: 2.6.0 -> 2.7.0 @wordpress/annotations: 1.10.0 -> 1.11.0 @wordpress/api-fetch: 3.9.0 -> 3.10.0 @wordpress/autop: 2.5.1 -> 2.6.0 @wordpress/blob: 2.6.0 -> 2.7.0 @wordpress/block-directory: 1.3.0 -> 1.4.0 @wordpress/block-editor: 3.5.0 -> 3.6.0 @wordpress/block-library: 2.12.0 -> 2.13.0 @wordpress/block-serialization-default-parser: 3.4.1 -> 3.5.0 @wordpress/blocks: 6.10.0 -> 6.11.0 @wordpress/components: 9.0.0 -> 9.1.0 @wordpress/compose: 3.10.0 -> 3.11.0 @wordpress/core-data: 2.10.0 -> 2.11.0 @wordpress/custom-templated-path-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/data: 4.12.0 -> 4.13.0 @wordpress/data-controls: 1.6.0 -> 1.7.0 @wordpress/date: 3.7.0 -> 3.8.0 @wordpress/dependency-extraction-webpack-plugin: 2.1.0 -> 2.2.0 @wordpress/deprecated: 2.6.1 -> 2.7.0 @wordpress/dom: 2.7.0 -> 2.8.0 @wordpress/dom-ready: 2.6.0 -> 2.7.0 @wordpress/e2e-test-utils: 4.1.0 -> 4.2.0 @wordpress/edit-post: 3.11.0 -> 3.12.0 @wordpress/editor: 9.10.0 -> 9.11.0 @wordpress/element: 2.10.0 -> 2.11.0 @wordpress/escape-html: 1.6.0 -> 1.7.0 @wordpress/format-library: 1.12.0 -> 1.13.0 @wordpress/hooks: 2.6.0 -> 2.7.0 @wordpress/html-entities: 2.5.0 -> 2.6.0 @wordpress/i18n: 3.8.0 -> 3.9.0 @wordpress/is-shallow-equal: 1.7.0 -> 1.8.0 @wordpress/keyboard-shortcuts: 0.2.0 -> 1.0.0 @wordpress/keycodes: 2.8.0 -> 2.9.0 @wordpress/library-export-default-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/list-reusable-blocks: 1.11.0 -> 1.12.0 @wordpress/media-utils: 1.5.0 -> 1.6.0 @wordpress/notices: 1.11.0 -> 1.12.0 @wordpress/nux: 3.10.0 -> 3.11.0 @wordpress/plugins: 2.10.0 -> 2.11.0 @wordpress/priority-queue: 1.4.0 -> 1.5.0 @wordpress/redux-routine: 3.6.2 -> 3.7.0 @wordpress/rich-text: 3.10.0 -> 3.11.0 @wordpress/scripts: 6.2.0 -> 7.0.0 @wordpress/server-side-render: 1.6.0 -> 1.7.0 @wordpress/shortcode: 2.5.0 -> 2.6.0 @wordpress/token-list: 1.8.0 -> 1.9.0 @wordpress/url: 2.9.0 -> 2.10.0 @wordpress/viewport: 2.11.0 -> 2.12.0 @wordpress/wordcount: 2.6.2 -> 2.7.0 Added these new packages: @wordpress/warning @wordpress/primitives @wordpress/icons Re-added keyboard-shortcuts to script loader removed by mistake on revision 47198. Props gziolo, itsjonq, youknowriad, mcsf, andraganescu. Fixes #49358. Built from https://develop.svn.wordpress.org/trunk@47199 git-svn-id: http://core.svn.wordpress.org/trunk@46999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 16:03:31 -05:00
// 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.
Block Editor: Update WordPress Packages. The following package versions were changed: @wordpress/a11y: 2.6.0 -> 2.7.0 @wordpress/annotations: 1.10.0 -> 1.11.0 @wordpress/api-fetch: 3.9.0 -> 3.10.0 @wordpress/autop: 2.5.1 -> 2.6.0 @wordpress/blob: 2.6.0 -> 2.7.0 @wordpress/block-directory: 1.3.0 -> 1.4.0 @wordpress/block-editor: 3.5.0 -> 3.6.0 @wordpress/block-library: 2.12.0 -> 2.13.0 @wordpress/block-serialization-default-parser: 3.4.1 -> 3.5.0 @wordpress/blocks: 6.10.0 -> 6.11.0 @wordpress/components: 9.0.0 -> 9.1.0 @wordpress/compose: 3.10.0 -> 3.11.0 @wordpress/core-data: 2.10.0 -> 2.11.0 @wordpress/custom-templated-path-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/data: 4.12.0 -> 4.13.0 @wordpress/data-controls: 1.6.0 -> 1.7.0 @wordpress/date: 3.7.0 -> 3.8.0 @wordpress/dependency-extraction-webpack-plugin: 2.1.0 -> 2.2.0 @wordpress/deprecated: 2.6.1 -> 2.7.0 @wordpress/dom: 2.7.0 -> 2.8.0 @wordpress/dom-ready: 2.6.0 -> 2.7.0 @wordpress/e2e-test-utils: 4.1.0 -> 4.2.0 @wordpress/edit-post: 3.11.0 -> 3.12.0 @wordpress/editor: 9.10.0 -> 9.11.0 @wordpress/element: 2.10.0 -> 2.11.0 @wordpress/escape-html: 1.6.0 -> 1.7.0 @wordpress/format-library: 1.12.0 -> 1.13.0 @wordpress/hooks: 2.6.0 -> 2.7.0 @wordpress/html-entities: 2.5.0 -> 2.6.0 @wordpress/i18n: 3.8.0 -> 3.9.0 @wordpress/is-shallow-equal: 1.7.0 -> 1.8.0 @wordpress/keyboard-shortcuts: 0.2.0 -> 1.0.0 @wordpress/keycodes: 2.8.0 -> 2.9.0 @wordpress/library-export-default-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/list-reusable-blocks: 1.11.0 -> 1.12.0 @wordpress/media-utils: 1.5.0 -> 1.6.0 @wordpress/notices: 1.11.0 -> 1.12.0 @wordpress/nux: 3.10.0 -> 3.11.0 @wordpress/plugins: 2.10.0 -> 2.11.0 @wordpress/priority-queue: 1.4.0 -> 1.5.0 @wordpress/redux-routine: 3.6.2 -> 3.7.0 @wordpress/rich-text: 3.10.0 -> 3.11.0 @wordpress/scripts: 6.2.0 -> 7.0.0 @wordpress/server-side-render: 1.6.0 -> 1.7.0 @wordpress/shortcode: 2.5.0 -> 2.6.0 @wordpress/token-list: 1.8.0 -> 1.9.0 @wordpress/url: 2.9.0 -> 2.10.0 @wordpress/viewport: 2.11.0 -> 2.12.0 @wordpress/wordcount: 2.6.2 -> 2.7.0 Added these new packages: @wordpress/warning @wordpress/primitives @wordpress/icons Re-added keyboard-shortcuts to script loader removed by mistake on revision 47198. Props gziolo, itsjonq, youknowriad, mcsf, andraganescu. Fixes #49358. Built from https://develop.svn.wordpress.org/trunk@47199 git-svn-id: http://core.svn.wordpress.org/trunk@46999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 16:03:31 -05:00
*
* @param {string} string Title or slug to be processed.
*
* @return {string} Processed string.
*/
function cleanForSlug(string) {
if (!string) {
return '';
}
return Object(external_lodash_["trim"])(Object(external_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-');
Block Editor: Update WordPress Packages. The following package versions were changed: @wordpress/a11y: 2.6.0 -> 2.7.0 @wordpress/annotations: 1.10.0 -> 1.11.0 @wordpress/api-fetch: 3.9.0 -> 3.10.0 @wordpress/autop: 2.5.1 -> 2.6.0 @wordpress/blob: 2.6.0 -> 2.7.0 @wordpress/block-directory: 1.3.0 -> 1.4.0 @wordpress/block-editor: 3.5.0 -> 3.6.0 @wordpress/block-library: 2.12.0 -> 2.13.0 @wordpress/block-serialization-default-parser: 3.4.1 -> 3.5.0 @wordpress/blocks: 6.10.0 -> 6.11.0 @wordpress/components: 9.0.0 -> 9.1.0 @wordpress/compose: 3.10.0 -> 3.11.0 @wordpress/core-data: 2.10.0 -> 2.11.0 @wordpress/custom-templated-path-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/data: 4.12.0 -> 4.13.0 @wordpress/data-controls: 1.6.0 -> 1.7.0 @wordpress/date: 3.7.0 -> 3.8.0 @wordpress/dependency-extraction-webpack-plugin: 2.1.0 -> 2.2.0 @wordpress/deprecated: 2.6.1 -> 2.7.0 @wordpress/dom: 2.7.0 -> 2.8.0 @wordpress/dom-ready: 2.6.0 -> 2.7.0 @wordpress/e2e-test-utils: 4.1.0 -> 4.2.0 @wordpress/edit-post: 3.11.0 -> 3.12.0 @wordpress/editor: 9.10.0 -> 9.11.0 @wordpress/element: 2.10.0 -> 2.11.0 @wordpress/escape-html: 1.6.0 -> 1.7.0 @wordpress/format-library: 1.12.0 -> 1.13.0 @wordpress/hooks: 2.6.0 -> 2.7.0 @wordpress/html-entities: 2.5.0 -> 2.6.0 @wordpress/i18n: 3.8.0 -> 3.9.0 @wordpress/is-shallow-equal: 1.7.0 -> 1.8.0 @wordpress/keyboard-shortcuts: 0.2.0 -> 1.0.0 @wordpress/keycodes: 2.8.0 -> 2.9.0 @wordpress/library-export-default-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/list-reusable-blocks: 1.11.0 -> 1.12.0 @wordpress/media-utils: 1.5.0 -> 1.6.0 @wordpress/notices: 1.11.0 -> 1.12.0 @wordpress/nux: 3.10.0 -> 3.11.0 @wordpress/plugins: 2.10.0 -> 2.11.0 @wordpress/priority-queue: 1.4.0 -> 1.5.0 @wordpress/redux-routine: 3.6.2 -> 3.7.0 @wordpress/rich-text: 3.10.0 -> 3.11.0 @wordpress/scripts: 6.2.0 -> 7.0.0 @wordpress/server-side-render: 1.6.0 -> 1.7.0 @wordpress/shortcode: 2.5.0 -> 2.6.0 @wordpress/token-list: 1.8.0 -> 1.9.0 @wordpress/url: 2.9.0 -> 2.10.0 @wordpress/viewport: 2.11.0 -> 2.12.0 @wordpress/wordcount: 2.6.2 -> 2.7.0 Added these new packages: @wordpress/warning @wordpress/primitives @wordpress/icons Re-added keyboard-shortcuts to script loader removed by mistake on revision 47198. Props gziolo, itsjonq, youknowriad, mcsf, andraganescu. Fixes #49358. Built from https://develop.svn.wordpress.org/trunk@47199 git-svn-id: http://core.svn.wordpress.org/trunk@46999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 16:03:31 -05:00
}
2020-01-08 06:57:23 -05:00
// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/index.js
Block Editor: Update WordPress Packages. The following package versions were changed: @wordpress/a11y: 2.6.0 -> 2.7.0 @wordpress/annotations: 1.10.0 -> 1.11.0 @wordpress/api-fetch: 3.9.0 -> 3.10.0 @wordpress/autop: 2.5.1 -> 2.6.0 @wordpress/blob: 2.6.0 -> 2.7.0 @wordpress/block-directory: 1.3.0 -> 1.4.0 @wordpress/block-editor: 3.5.0 -> 3.6.0 @wordpress/block-library: 2.12.0 -> 2.13.0 @wordpress/block-serialization-default-parser: 3.4.1 -> 3.5.0 @wordpress/blocks: 6.10.0 -> 6.11.0 @wordpress/components: 9.0.0 -> 9.1.0 @wordpress/compose: 3.10.0 -> 3.11.0 @wordpress/core-data: 2.10.0 -> 2.11.0 @wordpress/custom-templated-path-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/data: 4.12.0 -> 4.13.0 @wordpress/data-controls: 1.6.0 -> 1.7.0 @wordpress/date: 3.7.0 -> 3.8.0 @wordpress/dependency-extraction-webpack-plugin: 2.1.0 -> 2.2.0 @wordpress/deprecated: 2.6.1 -> 2.7.0 @wordpress/dom: 2.7.0 -> 2.8.0 @wordpress/dom-ready: 2.6.0 -> 2.7.0 @wordpress/e2e-test-utils: 4.1.0 -> 4.2.0 @wordpress/edit-post: 3.11.0 -> 3.12.0 @wordpress/editor: 9.10.0 -> 9.11.0 @wordpress/element: 2.10.0 -> 2.11.0 @wordpress/escape-html: 1.6.0 -> 1.7.0 @wordpress/format-library: 1.12.0 -> 1.13.0 @wordpress/hooks: 2.6.0 -> 2.7.0 @wordpress/html-entities: 2.5.0 -> 2.6.0 @wordpress/i18n: 3.8.0 -> 3.9.0 @wordpress/is-shallow-equal: 1.7.0 -> 1.8.0 @wordpress/keyboard-shortcuts: 0.2.0 -> 1.0.0 @wordpress/keycodes: 2.8.0 -> 2.9.0 @wordpress/library-export-default-webpack-plugin: 1.5.0 -> 1.6.0 @wordpress/list-reusable-blocks: 1.11.0 -> 1.12.0 @wordpress/media-utils: 1.5.0 -> 1.6.0 @wordpress/notices: 1.11.0 -> 1.12.0 @wordpress/nux: 3.10.0 -> 3.11.0 @wordpress/plugins: 2.10.0 -> 2.11.0 @wordpress/priority-queue: 1.4.0 -> 1.5.0 @wordpress/redux-routine: 3.6.2 -> 3.7.0 @wordpress/rich-text: 3.10.0 -> 3.11.0 @wordpress/scripts: 6.2.0 -> 7.0.0 @wordpress/server-side-render: 1.6.0 -> 1.7.0 @wordpress/shortcode: 2.5.0 -> 2.6.0 @wordpress/token-list: 1.8.0 -> 1.9.0 @wordpress/url: 2.9.0 -> 2.10.0 @wordpress/viewport: 2.11.0 -> 2.12.0 @wordpress/wordcount: 2.6.2 -> 2.7.0 Added these new packages: @wordpress/warning @wordpress/primitives @wordpress/icons Re-added keyboard-shortcuts to script loader removed by mistake on revision 47198. Props gziolo, itsjonq, youknowriad, mcsf, andraganescu. Fixes #49358. Built from https://develop.svn.wordpress.org/trunk@47199 git-svn-id: http://core.svn.wordpress.org/trunk@46999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 16:03:31 -05:00
/***/ })
/******/ });