[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 /******/ (function() { // webpackBootstrap 2 /******/ "use strict"; 3 /******/ // The require scope 4 /******/ var __webpack_require__ = {}; 5 /******/ 6 /************************************************************************/ 7 /******/ /* webpack/runtime/define property getters */ 8 /******/ !function() { 9 /******/ // define getter functions for harmony exports 10 /******/ __webpack_require__.d = function(exports, definition) { 11 /******/ for(var key in definition) { 12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14 /******/ } 15 /******/ } 16 /******/ }; 17 /******/ }(); 18 /******/ 19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 20 /******/ !function() { 21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 22 /******/ }(); 23 /******/ 24 /******/ /* webpack/runtime/make namespace object */ 25 /******/ !function() { 26 /******/ // define __esModule on exports 27 /******/ __webpack_require__.r = function(exports) { 28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30 /******/ } 31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 32 /******/ }; 33 /******/ }(); 34 /******/ 35 /************************************************************************/ 36 var __webpack_exports__ = {}; 37 // ESM COMPAT FLAG 38 __webpack_require__.r(__webpack_exports__); 39 40 // EXPORTS 41 __webpack_require__.d(__webpack_exports__, { 42 "addQueryArgs": function() { return /* reexport */ addQueryArgs; }, 43 "buildQueryString": function() { return /* reexport */ buildQueryString; }, 44 "cleanForSlug": function() { return /* reexport */ cleanForSlug; }, 45 "filterURLForDisplay": function() { return /* reexport */ filterURLForDisplay; }, 46 "getAuthority": function() { return /* reexport */ getAuthority; }, 47 "getFilename": function() { return /* reexport */ getFilename; }, 48 "getFragment": function() { return /* reexport */ getFragment; }, 49 "getPath": function() { return /* reexport */ getPath; }, 50 "getPathAndQueryString": function() { return /* reexport */ getPathAndQueryString; }, 51 "getProtocol": function() { return /* reexport */ getProtocol; }, 52 "getQueryArg": function() { return /* reexport */ getQueryArg; }, 53 "getQueryArgs": function() { return /* reexport */ getQueryArgs; }, 54 "getQueryString": function() { return /* reexport */ getQueryString; }, 55 "hasQueryArg": function() { return /* reexport */ hasQueryArg; }, 56 "isEmail": function() { return /* reexport */ isEmail; }, 57 "isURL": function() { return /* reexport */ isURL; }, 58 "isValidAuthority": function() { return /* reexport */ isValidAuthority; }, 59 "isValidFragment": function() { return /* reexport */ isValidFragment; }, 60 "isValidPath": function() { return /* reexport */ isValidPath; }, 61 "isValidProtocol": function() { return /* reexport */ isValidProtocol; }, 62 "isValidQueryString": function() { return /* reexport */ isValidQueryString; }, 63 "normalizePath": function() { return /* reexport */ normalizePath; }, 64 "prependHTTP": function() { return /* reexport */ prependHTTP; }, 65 "removeQueryArgs": function() { return /* reexport */ removeQueryArgs; }, 66 "safeDecodeURI": function() { return /* reexport */ safeDecodeURI; }, 67 "safeDecodeURIComponent": function() { return /* reexport */ safeDecodeURIComponent; } 68 }); 69 70 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-url.js 71 /** 72 * Determines whether the given string looks like a URL. 73 * 74 * @param {string} url The string to scrutinise. 75 * 76 * @example 77 * ```js 78 * const isURL = isURL( 'https://wordpress.org' ); // true 79 * ``` 80 * 81 * @see https://url.spec.whatwg.org/ 82 * @see https://url.spec.whatwg.org/#valid-url-string 83 * 84 * @return {boolean} Whether or not it looks like a URL. 85 */ 86 function isURL(url) { 87 // A URL can be considered value if the `URL` constructor is able to parse 88 // it. The constructor throws an error for an invalid URL. 89 try { 90 new URL(url); 91 return true; 92 } catch { 93 return false; 94 } 95 } 96 97 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-email.js 98 const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; 99 /** 100 * Determines whether the given string looks like an email. 101 * 102 * @param {string} email The string to scrutinise. 103 * 104 * @example 105 * ```js 106 * const isEmail = isEmail( 'hello@wordpress.org' ); // true 107 * ``` 108 * 109 * @return {boolean} Whether or not it looks like an email. 110 */ 111 112 function isEmail(email) { 113 return EMAIL_REGEXP.test(email); 114 } 115 116 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-protocol.js 117 /** 118 * Returns the protocol part of the URL. 119 * 120 * @param {string} url The full URL. 121 * 122 * @example 123 * ```js 124 * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' 125 * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' 126 * ``` 127 * 128 * @return {string|void} The protocol part of the URL. 129 */ 130 function getProtocol(url) { 131 const matches = /^([^\s:]+:)/.exec(url); 132 133 if (matches) { 134 return matches[1]; 135 } 136 } 137 138 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-protocol.js 139 /** 140 * Tests if a url protocol is valid. 141 * 142 * @param {string} protocol The url protocol. 143 * 144 * @example 145 * ```js 146 * const isValid = isValidProtocol( 'https:' ); // true 147 * const isNotValid = isValidProtocol( 'https :' ); // false 148 * ``` 149 * 150 * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). 151 */ 152 function isValidProtocol(protocol) { 153 if (!protocol) { 154 return false; 155 } 156 157 return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); 158 } 159 160 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-authority.js 161 /** 162 * Returns the authority part of the URL. 163 * 164 * @param {string} url The full URL. 165 * 166 * @example 167 * ```js 168 * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' 169 * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' 170 * ``` 171 * 172 * @return {string|void} The authority part of the URL. 173 */ 174 function getAuthority(url) { 175 const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); 176 177 if (matches) { 178 return matches[1]; 179 } 180 } 181 182 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-authority.js 183 /** 184 * Checks for invalid characters within the provided authority. 185 * 186 * @param {string} authority A string containing the URL authority. 187 * 188 * @example 189 * ```js 190 * const isValid = isValidAuthority( 'wordpress.org' ); // true 191 * const isNotValid = isValidAuthority( 'wordpress#org' ); // false 192 * ``` 193 * 194 * @return {boolean} True if the argument contains a valid authority. 195 */ 196 function isValidAuthority(authority) { 197 if (!authority) { 198 return false; 199 } 200 201 return /^[^\s#?]+$/.test(authority); 202 } 203 204 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path.js 205 /** 206 * Returns the path part of the URL. 207 * 208 * @param {string} url The full URL. 209 * 210 * @example 211 * ```js 212 * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' 213 * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' 214 * ``` 215 * 216 * @return {string|void} The path part of the URL. 217 */ 218 function getPath(url) { 219 const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); 220 221 if (matches) { 222 return matches[1]; 223 } 224 } 225 226 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-path.js 227 /** 228 * Checks for invalid characters within the provided path. 229 * 230 * @param {string} path The URL path. 231 * 232 * @example 233 * ```js 234 * const isValid = isValidPath( 'test/path/' ); // true 235 * const isNotValid = isValidPath( '/invalid?test/path/' ); // false 236 * ``` 237 * 238 * @return {boolean} True if the argument contains a valid path 239 */ 240 function isValidPath(path) { 241 if (!path) { 242 return false; 243 } 244 245 return /^[^\s#?]+$/.test(path); 246 } 247 248 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-string.js 249 /** 250 * Returns the query string part of the URL. 251 * 252 * @param {string} url The full URL. 253 * 254 * @example 255 * ```js 256 * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' 257 * ``` 258 * 259 * @return {string|void} The query string part of the URL. 260 */ 261 function getQueryString(url) { 262 let query; 263 264 try { 265 query = new URL(url, 'http://example.com').search.substring(1); 266 } catch (error) {} 267 268 if (query) { 269 return query; 270 } 271 } 272 273 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/build-query-string.js 274 /** 275 * Generates URL-encoded query string using input query data. 276 * 277 * It is intended to behave equivalent as PHP's `http_build_query`, configured 278 * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`). 279 * 280 * @example 281 * ```js 282 * const queryString = buildQueryString( { 283 * simple: 'is ok', 284 * arrays: [ 'are', 'fine', 'too' ], 285 * objects: { 286 * evenNested: { 287 * ok: 'yes', 288 * }, 289 * }, 290 * } ); 291 * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes" 292 * ``` 293 * 294 * @param {Record<string,*>} data Data to encode. 295 * 296 * @return {string} Query string. 297 */ 298 function buildQueryString(data) { 299 let string = ''; 300 const stack = Object.entries(data); 301 let pair; 302 303 while (pair = stack.shift()) { 304 let [key, value] = pair; // Support building deeply nested data, from array or object values. 305 306 const hasNestedData = Array.isArray(value) || value && value.constructor === Object; 307 308 if (hasNestedData) { 309 // Push array or object values onto the stack as composed of their 310 // original key and nested index or key, retaining order by a 311 // combination of Array#reverse and Array#unshift onto the stack. 312 const valuePairs = Object.entries(value).reverse(); 313 314 for (const [member, memberValue] of valuePairs) { 315 stack.unshift([`$key}[$member}]`, memberValue]); 316 } 317 } else if (value !== undefined) { 318 // Null is treated as special case, equivalent to empty string. 319 if (value === null) { 320 value = ''; 321 } 322 323 string += '&' + [key, value].map(encodeURIComponent).join('='); 324 } 325 } // Loop will concatenate with leading `&`, but it's only expected for all 326 // but the first query parameter. This strips the leading `&`, while still 327 // accounting for the case that the string may in-fact be empty. 328 329 330 return string.substr(1); 331 } 332 333 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-query-string.js 334 /** 335 * Checks for invalid characters within the provided query string. 336 * 337 * @param {string} queryString The query string. 338 * 339 * @example 340 * ```js 341 * const isValid = isValidQueryString( 'query=true&another=false' ); // true 342 * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false 343 * ``` 344 * 345 * @return {boolean} True if the argument contains a valid query string. 346 */ 347 function isValidQueryString(queryString) { 348 if (!queryString) { 349 return false; 350 } 351 352 return /^[^\s#?\/]+$/.test(queryString); 353 } 354 355 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path-and-query-string.js 356 /** 357 * Internal dependencies 358 */ 359 360 /** 361 * Returns the path part and query string part of the URL. 362 * 363 * @param {string} url The full URL. 364 * 365 * @example 366 * ```js 367 * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true' 368 * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq' 369 * ``` 370 * 371 * @return {string} The path part and query string part of the URL. 372 */ 373 374 function getPathAndQueryString(url) { 375 const path = getPath(url); 376 const queryString = getQueryString(url); 377 let value = '/'; 378 if (path) value += path; 379 if (queryString) value += `?$queryString}`; 380 return value; 381 } 382 383 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-fragment.js 384 /** 385 * Returns the fragment part of the URL. 386 * 387 * @param {string} url The full URL 388 * 389 * @example 390 * ```js 391 * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' 392 * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' 393 * ``` 394 * 395 * @return {string|void} The fragment part of the URL. 396 */ 397 function getFragment(url) { 398 const matches = /^\S+?(#[^\s\?]*)/.exec(url); 399 400 if (matches) { 401 return matches[1]; 402 } 403 } 404 405 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-fragment.js 406 /** 407 * Checks for invalid characters within the provided fragment. 408 * 409 * @param {string} fragment The url fragment. 410 * 411 * @example 412 * ```js 413 * const isValid = isValidFragment( '#valid-fragment' ); // true 414 * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false 415 * ``` 416 * 417 * @return {boolean} True if the argument contains a valid fragment. 418 */ 419 function isValidFragment(fragment) { 420 if (!fragment) { 421 return false; 422 } 423 424 return /^#[^\s#?\/]*$/.test(fragment); 425 } 426 427 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-args.js 428 /** 429 * Internal dependencies 430 */ 431 432 /** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */ 433 434 /** 435 * @typedef {Record<string,QueryArgParsed>} QueryArgs 436 */ 437 438 /** 439 * Sets a value in object deeply by a given array of path segments. Mutates the 440 * object reference. 441 * 442 * @param {Record<string,*>} object Object in which to assign. 443 * @param {string[]} path Path segment at which to set value. 444 * @param {*} value Value to set. 445 */ 446 447 function setPath(object, path, value) { 448 const length = path.length; 449 const lastIndex = length - 1; 450 451 for (let i = 0; i < length; i++) { 452 let key = path[i]; 453 454 if (!key && Array.isArray(object)) { 455 // If key is empty string and next value is array, derive key from 456 // the current length of the array. 457 key = object.length.toString(); 458 } 459 460 key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be 461 // created as an array. Otherwise, it will be created as an object. 462 463 const isNextKeyArrayIndex = !isNaN(Number(path[i + 1])); 464 object[key] = i === lastIndex ? // If at end of path, assign the intended value. 465 value : // Otherwise, advance to the next object in the path, creating 466 // it if it does not yet exist. 467 object[key] || (isNextKeyArrayIndex ? [] : {}); 468 469 if (Array.isArray(object[key]) && !isNextKeyArrayIndex) { 470 // If we current key is non-numeric, but the next value is an 471 // array, coerce the value to an object. 472 object[key] = { ...object[key] 473 }; 474 } // Update working reference object to the next in the path. 475 476 477 object = object[key]; 478 } 479 } 480 /** 481 * Returns an object of query arguments of the given URL. If the given URL is 482 * invalid or has no querystring, an empty object is returned. 483 * 484 * @param {string} url URL. 485 * 486 * @example 487 * ```js 488 * const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' ); 489 * // { "foo": "bar", "bar": "baz" } 490 * ``` 491 * 492 * @return {QueryArgs} Query args object. 493 */ 494 495 496 function getQueryArgs(url) { 497 return (getQueryString(url) || '' // Normalize space encoding, accounting for PHP URL encoding 498 // corresponding to `application/x-www-form-urlencoded`. 499 // 500 // See: https://tools.ietf.org/html/rfc1866#section-8.2.1 501 ).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => { 502 const [key, value = ''] = keyValue.split('=') // Filtering avoids decoding as `undefined` for value, where 503 // default is restored in destructuring assignment. 504 .filter(Boolean).map(decodeURIComponent); 505 506 if (key) { 507 const segments = key.replace(/\]/g, '').split('['); 508 setPath(accumulator, segments, value); 509 } 510 511 return accumulator; 512 }, Object.create(null)); 513 } 514 515 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js 516 /** 517 * Internal dependencies 518 */ 519 520 521 /** 522 * Appends arguments as querystring to the provided URL. If the URL already 523 * includes query arguments, the arguments are merged with (and take precedent 524 * over) the existing set. 525 * 526 * @param {string} [url=''] URL to which arguments should be appended. If omitted, 527 * only the resulting querystring is returned. 528 * @param {Object} [args] Query arguments to apply to URL. 529 * 530 * @example 531 * ```js 532 * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test 533 * ``` 534 * 535 * @return {string} URL with arguments applied. 536 */ 537 538 function addQueryArgs() { 539 let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 540 let args = arguments.length > 1 ? arguments[1] : undefined; 541 542 // If no arguments are to be appended, return original URL. 543 if (!args || !Object.keys(args).length) { 544 return url; 545 } 546 547 let baseUrl = url; // Determine whether URL already had query arguments. 548 549 const queryStringIndex = url.indexOf('?'); 550 551 if (queryStringIndex !== -1) { 552 // Merge into existing query arguments. 553 args = Object.assign(getQueryArgs(url), args); // Change working base URL to omit previous query arguments. 554 555 baseUrl = baseUrl.substr(0, queryStringIndex); 556 } 557 558 return baseUrl + '?' + buildQueryString(args); 559 } 560 561 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js 562 /** 563 * Internal dependencies 564 */ 565 566 /** 567 * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject 568 */ 569 570 /** 571 * @typedef {string|string[]|QueryArgObject} QueryArgParsed 572 */ 573 574 /** 575 * Returns a single query argument of the url 576 * 577 * @param {string} url URL. 578 * @param {string} arg Query arg name. 579 * 580 * @example 581 * ```js 582 * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar 583 * ``` 584 * 585 * @return {QueryArgParsed|void} Query arg value. 586 */ 587 588 function getQueryArg(url, arg) { 589 return getQueryArgs(url)[arg]; 590 } 591 592 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js 593 /** 594 * Internal dependencies 595 */ 596 597 /** 598 * Determines whether the URL contains a given query arg. 599 * 600 * @param {string} url URL. 601 * @param {string} arg Query arg name. 602 * 603 * @example 604 * ```js 605 * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true 606 * ``` 607 * 608 * @return {boolean} Whether or not the URL contains the query arg. 609 */ 610 611 function hasQueryArg(url, arg) { 612 return getQueryArg(url, arg) !== undefined; 613 } 614 615 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js 616 /** 617 * Internal dependencies 618 */ 619 620 621 /** 622 * Removes arguments from the query string of the url 623 * 624 * @param {string} url URL. 625 * @param {...string} args Query Args. 626 * 627 * @example 628 * ```js 629 * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar 630 * ``` 631 * 632 * @return {string} Updated URL. 633 */ 634 635 function removeQueryArgs(url) { 636 const queryStringIndex = url.indexOf('?'); 637 638 if (queryStringIndex === -1) { 639 return url; 640 } 641 642 const query = getQueryArgs(url); 643 const baseURL = url.substr(0, queryStringIndex); 644 645 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 646 args[_key - 1] = arguments[_key]; 647 } 648 649 args.forEach(arg => delete query[arg]); 650 const queryString = buildQueryString(query); 651 return queryString ? baseURL + '?' + queryString : baseURL; 652 } 653 654 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js 655 /** 656 * Internal dependencies 657 */ 658 659 const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; 660 /** 661 * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. 662 * 663 * @param {string} url The URL to test. 664 * 665 * @example 666 * ```js 667 * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org 668 * ``` 669 * 670 * @return {string} The updated URL. 671 */ 672 673 function prependHTTP(url) { 674 if (!url) { 675 return url; 676 } 677 678 url = url.trim(); 679 680 if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) { 681 return 'http://' + url; 682 } 683 684 return url; 685 } 686 687 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri.js 688 /** 689 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if 690 * `decodeURI` throws an error. 691 * 692 * @param {string} uri URI to decode. 693 * 694 * @example 695 * ```js 696 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' 697 * ``` 698 * 699 * @return {string} Decoded URI if possible. 700 */ 701 function safeDecodeURI(uri) { 702 try { 703 return decodeURI(uri); 704 } catch (uriError) { 705 return uri; 706 } 707 } 708 709 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri-component.js 710 /** 711 * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if 712 * `decodeURIComponent` throws an error. 713 * 714 * @param {string} uriComponent URI component to decode. 715 * 716 * @return {string} Decoded URI component if possible. 717 */ 718 function safeDecodeURIComponent(uriComponent) { 719 try { 720 return decodeURIComponent(uriComponent); 721 } catch (uriComponentError) { 722 return uriComponent; 723 } 724 } 725 726 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/filter-url-for-display.js 727 /** 728 * Returns a URL for display. 729 * 730 * @param {string} url Original URL. 731 * @param {number|null} maxLength URL length. 732 * 733 * @example 734 * ```js 735 * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg 736 * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png 737 * ``` 738 * 739 * @return {string} Displayed URL. 740 */ 741 function filterURLForDisplay(url) { 742 let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 743 // Remove protocol and www prefixes. 744 let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. 745 746 if (filteredURL.match(/^[^\/]+\/$/)) { 747 filteredURL = filteredURL.replace('/', ''); 748 } 749 750 const mediaRegexp = /([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/; 751 752 if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(mediaRegexp)) { 753 return filteredURL; 754 } // If the file is not greater than max length, return last portion of URL. 755 756 757 filteredURL = filteredURL.split('?')[0]; 758 const urlPieces = filteredURL.split('/'); 759 const file = urlPieces[urlPieces.length - 1]; 760 761 if (file.length <= maxLength) { 762 return '…' + filteredURL.slice(-maxLength); 763 } // If the file is greater than max length, truncate the file. 764 765 766 const index = file.lastIndexOf('.'); 767 const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)]; 768 const truncatedFile = fileName.slice(-3) + '.' + extension; 769 return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile; 770 } 771 772 ;// CONCATENATED MODULE: external "lodash" 773 var external_lodash_namespaceObject = window["lodash"]; 774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/clean-for-slug.js 775 /** 776 * External dependencies 777 */ 778 779 /** 780 * Performs some basic cleanup of a string for use as a post slug. 781 * 782 * This replicates some of what `sanitize_title()` does in WordPress core, but 783 * is only designed to approximate what the slug will be. 784 * 785 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin 786 * letters. Removes combining diacritical marks. Converts whitespace, periods, 787 * and forward slashes to hyphens. Removes any remaining non-word characters 788 * except hyphens. Converts remaining string to lowercase. It does not account 789 * for octets, HTML entities, or other encoded characters. 790 * 791 * @param {string} string Title or slug to be processed. 792 * 793 * @return {string} Processed string. 794 */ 795 796 function cleanForSlug(string) { 797 if (!string) { 798 return ''; 799 } 800 801 return (0,external_lodash_namespaceObject.trim)((0,external_lodash_namespaceObject.deburr)(string).replace(/[\s\./]+/g, '-').replace(/[^\p{L}\p{N}_-]+/gu, '').toLowerCase(), '-'); 802 } 803 804 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-filename.js 805 /** 806 * Returns the filename part of the URL. 807 * 808 * @param {string} url The full URL. 809 * 810 * @example 811 * ```js 812 * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg' 813 * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png' 814 * ``` 815 * 816 * @return {string|void} The filename part of the URL. 817 */ 818 function getFilename(url) { 819 let filename; 820 821 try { 822 filename = new URL(url, 'http://example.com').pathname.split('/').pop(); 823 } catch (error) {} 824 825 if (filename) { 826 return filename; 827 } 828 } 829 830 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/normalize-path.js 831 /** 832 * Given a path, returns a normalized path where equal query parameter values 833 * will be treated as identical, regardless of order they appear in the original 834 * text. 835 * 836 * @param {string} path Original path. 837 * 838 * @return {string} Normalized path. 839 */ 840 function normalizePath(path) { 841 const splitted = path.split('?'); 842 const query = splitted[1]; 843 const base = splitted[0]; 844 845 if (!query) { 846 return base; 847 } // 'b=1%2C2&c=2&a=5' 848 849 850 return base + '?' + query // [ 'b=1%2C2', 'c=2', 'a=5' ] 851 .split('&') // [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ] 852 .map(entry => entry.split('=')) // [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ] 853 .map(pair => pair.map(decodeURIComponent)) // [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ] 854 .sort((a, b) => a[0].localeCompare(b[0])) // [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ] 855 .map(pair => pair.map(encodeURIComponent)) // [ 'a=5', 'b=1%2C2', 'c=2' ] 856 .map(pair => pair.join('=')) // 'a=5&b=1%2C2&c=2' 857 .join('&'); 858 } 859 860 ;// CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/index.js 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 (window.wp = window.wp || {}).url = __webpack_exports__; 889 /******/ })() 890 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |