diff -r 48c4eec2b7e6 -r 8c2e4d02f4ef wp/wp-includes/js/dist/url.js --- a/wp/wp-includes/js/dist/url.js Fri Sep 05 18:40:08 2025 +0200 +++ b/wp/wp-includes/js/dist/url.js Fri Sep 05 18:52:52 2025 +0200 @@ -558,7 +558,7 @@ /******/ /************************************************************************/ var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be in strict mode. +// This entry needs to be wrapped in an IIFE because it needs to be in strict mode. (() => { "use strict"; // ESM COMPAT FLAG @@ -581,6 +581,7 @@ getQueryString: () => (/* reexport */ getQueryString), hasQueryArg: () => (/* reexport */ hasQueryArg), isEmail: () => (/* reexport */ isEmail), + isPhoneNumber: () => (/* reexport */ isPhoneNumber), isURL: () => (/* reexport */ isURL), isValidAuthority: () => (/* reexport */ isValidAuthority), isValidFragment: () => (/* reexport */ isValidFragment), @@ -595,7 +596,8 @@ safeDecodeURIComponent: () => (/* reexport */ safeDecodeURIComponent) }); -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-url.js +;// ./node_modules/@wordpress/url/build-module/is-url.js +/* wp:polyfill */ /** * Determines whether the given string looks like a URL. * @@ -622,7 +624,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-email.js +;// ./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; /** @@ -641,7 +643,28 @@ return EMAIL_REGEXP.test(email); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-protocol.js +;// ./node_modules/@wordpress/url/build-module/is-phone-number.js +const PHONE_REGEXP = /^(tel:)?(\+)?\d{6,15}$/; + +/** + * Determines whether the given string looks like a phone number. + * + * @param {string} phoneNumber The string to scrutinize. + * + * @example + * ```js + * const isPhoneNumber = isPhoneNumber('+1 (555) 123-4567'); // true + * ``` + * + * @return {boolean} Whether or not it looks like a phone number. + */ +function isPhoneNumber(phoneNumber) { + // Remove any separator from phone number. + phoneNumber = phoneNumber.replace(/[-.() ]/g, ''); + return PHONE_REGEXP.test(phoneNumber); +} + +;// ./node_modules/@wordpress/url/build-module/get-protocol.js /** * Returns the protocol part of the URL. * @@ -662,7 +685,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-protocol.js +;// ./node_modules/@wordpress/url/build-module/is-valid-protocol.js /** * Tests if a url protocol is valid. * @@ -683,7 +706,7 @@ return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-authority.js +;// ./node_modules/@wordpress/url/build-module/get-authority.js /** * Returns the authority part of the URL. * @@ -704,7 +727,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-authority.js +;// ./node_modules/@wordpress/url/build-module/is-valid-authority.js /** * Checks for invalid characters within the provided authority. * @@ -725,7 +748,7 @@ return /^[^\s#?]+$/.test(authority); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path.js +;// ./node_modules/@wordpress/url/build-module/get-path.js /** * Returns the path part of the URL. * @@ -746,7 +769,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-path.js +;// ./node_modules/@wordpress/url/build-module/is-valid-path.js /** * Checks for invalid characters within the provided path. * @@ -767,7 +790,8 @@ return /^[^\s#?]+$/.test(path); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-string.js +;// ./node_modules/@wordpress/url/build-module/get-query-string.js +/* wp:polyfill */ /** * Returns the query string part of the URL. * @@ -790,7 +814,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/build-query-string.js +;// ./node_modules/@wordpress/url/build-module/build-query-string.js /** * Generates URL-encoded query string using input query data. * @@ -847,7 +871,7 @@ return string.substr(1); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-query-string.js +;// ./node_modules/@wordpress/url/build-module/is-valid-query-string.js /** * Checks for invalid characters within the provided query string. * @@ -868,7 +892,7 @@ return /^[^\s#?\/]+$/.test(queryString); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path-and-query-string.js +;// ./node_modules/@wordpress/url/build-module/get-path-and-query-string.js /** * Internal dependencies */ @@ -900,7 +924,7 @@ return value; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-fragment.js +;// ./node_modules/@wordpress/url/build-module/get-fragment.js /** * Returns the fragment part of the URL. * @@ -921,7 +945,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-fragment.js +;// ./node_modules/@wordpress/url/build-module/is-valid-fragment.js /** * Checks for invalid characters within the provided fragment. * @@ -942,7 +966,7 @@ return /^#[^\s#?\/]*$/.test(fragment); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri-component.js +;// ./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. @@ -959,7 +983,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-args.js +;// ./node_modules/@wordpress/url/build-module/get-query-args.js /** * Internal dependencies */ @@ -1047,13 +1071,14 @@ }, Object.create(null)); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js +;// ./node_modules/@wordpress/url/build-module/add-query-args.js /** * 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 @@ -1075,7 +1100,8 @@ if (!args || !Object.keys(args).length) { return url; } - let baseUrl = url; + const fragment = getFragment(url) || ''; + let baseUrl = url.replace(fragment, ''); // Determine whether URL already had query arguments. const queryStringIndex = url.indexOf('?'); @@ -1086,10 +1112,10 @@ // Change working base URL to omit previous query arguments. baseUrl = baseUrl.substr(0, queryStringIndex); } - return baseUrl + '?' + buildQueryString(args); + return baseUrl + '?' + buildQueryString(args) + fragment; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js +;// ./node_modules/@wordpress/url/build-module/get-query-arg.js /** * Internal dependencies */ @@ -1120,7 +1146,7 @@ return getQueryArgs(url)[arg]; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js +;// ./node_modules/@wordpress/url/build-module/has-query-arg.js /** * Internal dependencies */ @@ -1143,7 +1169,7 @@ return getQueryArg(url, arg) !== undefined; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js +;// ./node_modules/@wordpress/url/build-module/remove-query-args.js /** * Internal dependencies */ @@ -1164,18 +1190,21 @@ * @return {string} Updated URL. */ function removeQueryArgs(url, ...args) { + const fragment = url.replace(/^[^#]*/, ''); + url = url.replace(/#.*/, ''); const queryStringIndex = url.indexOf('?'); if (queryStringIndex === -1) { - return url; + return url + fragment; } 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; + const updatedUrl = queryString ? baseURL + '?' + queryString : baseURL; + return updatedUrl + fragment; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js +;// ./node_modules/@wordpress/url/build-module/prepend-http.js /** * Internal dependencies */ @@ -1205,7 +1234,7 @@ return url; } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri.js +;// ./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. @@ -1227,7 +1256,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/filter-url-for-display.js +;// ./node_modules/@wordpress/url/build-module/filter-url-for-display.js /** * Returns a URL for display. * @@ -1243,8 +1272,12 @@ * @return {string} Displayed URL. */ function filterURLForDisplay(url, maxLength = null) { + if (!url) { + return ''; + } + // Remove protocol and www prefixes. - let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); + let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, '').replace(/^www\./i, ''); // Ends with / and only has that single slash, strip it. if (filteredURL.match(/^[^\/]+\/$/)) { @@ -1275,7 +1308,7 @@ // EXTERNAL MODULE: ./node_modules/remove-accents/index.js var remove_accents = __webpack_require__(9681); var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/clean-for-slug.js +;// ./node_modules/@wordpress/url/build-module/clean-for-slug.js /** * External dependencies */ @@ -1284,7 +1317,7 @@ /** * 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 + * This replicates some of what `sanitize_title_with_dashes()` 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 @@ -1302,8 +1335,12 @@ return ''; } return remove_accents_default()(string) + // Convert  , &ndash, and &mdash to hyphens. + .replace(/( |–|—)/g, '-') // Convert each group of whitespace, periods, and forward slashes to a hyphen. .replace(/[\s\./]+/g, '-') + // Remove all HTML entities. + .replace(/&\S+?;/g, '') // Remove anything that's not a letter, number, underscore or hyphen. .replace(/[^\p{L}\p{N}_-]+/gu, '') // Convert to lowercase @@ -1314,7 +1351,8 @@ .replace(/(^-+)|(-+$)/g, ''); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-filename.js +;// ./node_modules/@wordpress/url/build-module/get-filename.js +/* wp:polyfill */ /** * Returns the filename part of the URL. * @@ -1341,7 +1379,7 @@ } } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/normalize-path.js +;// ./node_modules/@wordpress/url/build-module/normalize-path.js /** * Given a path, returns a normalized path where equal query parameter values * will be treated as identical, regardless of order they appear in the original @@ -1352,9 +1390,9 @@ * @return {string} Normalized path. */ function normalizePath(path) { - const splitted = path.split('?'); - const query = splitted[1]; - const base = splitted[0]; + const split = path.split('?'); + const query = split[1]; + const base = split[0]; if (!query) { return base; } @@ -1377,7 +1415,7 @@ .join('&'); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-https.js +;// ./node_modules/@wordpress/url/build-module/prepend-https.js /** * Internal dependencies */ @@ -1410,7 +1448,8 @@ return url.replace(/^http:/, 'https:'); } -;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/index.js +;// ./node_modules/@wordpress/url/build-module/index.js +