[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> url.js (source)

   1  (function() {
   2  "use strict";
   3  var wp;
   4  (wp ||= {}).url = (() => {
   5    var __create = Object.create;
   6    var __defProp = Object.defineProperty;
   7    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   8    var __getOwnPropNames = Object.getOwnPropertyNames;
   9    var __getProtoOf = Object.getPrototypeOf;
  10    var __hasOwnProp = Object.prototype.hasOwnProperty;
  11    var __commonJS = (cb, mod) => function __require() {
  12      return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  13    };
  14    var __export = (target, all) => {
  15      for (var name in all)
  16        __defProp(target, name, { get: all[name], enumerable: true });
  17    };
  18    var __copyProps = (to, from, except, desc) => {
  19      if (from && typeof from === "object" || typeof from === "function") {
  20        for (let key of __getOwnPropNames(from))
  21          if (!__hasOwnProp.call(to, key) && key !== except)
  22            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  23      }
  24      return to;
  25    };
  26    var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  27      // If the importer is in node compatibility mode or this is not an ESM
  28      // file that has been converted to a CommonJS file using a Babel-
  29      // compatible transform (i.e. "__esModule" has not been set), then set
  30      // "default" to the CommonJS "module.exports" for node compatibility.
  31      isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  32      mod
  33    ));
  34    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  35  
  36    // node_modules/remove-accents/index.js
  37    var require_remove_accents = __commonJS({
  38      "node_modules/remove-accents/index.js"(exports, module) {
  39        var characterMap = {
  40          "\xC0": "A",
  41          "\xC1": "A",
  42          "\xC2": "A",
  43          "\xC3": "A",
  44          "\xC4": "A",
  45          "\xC5": "A",
  46          "\u1EA4": "A",
  47          "\u1EAE": "A",
  48          "\u1EB2": "A",
  49          "\u1EB4": "A",
  50          "\u1EB6": "A",
  51          "\xC6": "AE",
  52          "\u1EA6": "A",
  53          "\u1EB0": "A",
  54          "\u0202": "A",
  55          "\u1EA2": "A",
  56          "\u1EA0": "A",
  57          "\u1EA8": "A",
  58          "\u1EAA": "A",
  59          "\u1EAC": "A",
  60          "\xC7": "C",
  61          "\u1E08": "C",
  62          "\xC8": "E",
  63          "\xC9": "E",
  64          "\xCA": "E",
  65          "\xCB": "E",
  66          "\u1EBE": "E",
  67          "\u1E16": "E",
  68          "\u1EC0": "E",
  69          "\u1E14": "E",
  70          "\u1E1C": "E",
  71          "\u0206": "E",
  72          "\u1EBA": "E",
  73          "\u1EBC": "E",
  74          "\u1EB8": "E",
  75          "\u1EC2": "E",
  76          "\u1EC4": "E",
  77          "\u1EC6": "E",
  78          "\xCC": "I",
  79          "\xCD": "I",
  80          "\xCE": "I",
  81          "\xCF": "I",
  82          "\u1E2E": "I",
  83          "\u020A": "I",
  84          "\u1EC8": "I",
  85          "\u1ECA": "I",
  86          "\xD0": "D",
  87          "\xD1": "N",
  88          "\xD2": "O",
  89          "\xD3": "O",
  90          "\xD4": "O",
  91          "\xD5": "O",
  92          "\xD6": "O",
  93          "\xD8": "O",
  94          "\u1ED0": "O",
  95          "\u1E4C": "O",
  96          "\u1E52": "O",
  97          "\u020E": "O",
  98          "\u1ECE": "O",
  99          "\u1ECC": "O",
 100          "\u1ED4": "O",
 101          "\u1ED6": "O",
 102          "\u1ED8": "O",
 103          "\u1EDC": "O",
 104          "\u1EDE": "O",
 105          "\u1EE0": "O",
 106          "\u1EDA": "O",
 107          "\u1EE2": "O",
 108          "\xD9": "U",
 109          "\xDA": "U",
 110          "\xDB": "U",
 111          "\xDC": "U",
 112          "\u1EE6": "U",
 113          "\u1EE4": "U",
 114          "\u1EEC": "U",
 115          "\u1EEE": "U",
 116          "\u1EF0": "U",
 117          "\xDD": "Y",
 118          "\xE0": "a",
 119          "\xE1": "a",
 120          "\xE2": "a",
 121          "\xE3": "a",
 122          "\xE4": "a",
 123          "\xE5": "a",
 124          "\u1EA5": "a",
 125          "\u1EAF": "a",
 126          "\u1EB3": "a",
 127          "\u1EB5": "a",
 128          "\u1EB7": "a",
 129          "\xE6": "ae",
 130          "\u1EA7": "a",
 131          "\u1EB1": "a",
 132          "\u0203": "a",
 133          "\u1EA3": "a",
 134          "\u1EA1": "a",
 135          "\u1EA9": "a",
 136          "\u1EAB": "a",
 137          "\u1EAD": "a",
 138          "\xE7": "c",
 139          "\u1E09": "c",
 140          "\xE8": "e",
 141          "\xE9": "e",
 142          "\xEA": "e",
 143          "\xEB": "e",
 144          "\u1EBF": "e",
 145          "\u1E17": "e",
 146          "\u1EC1": "e",
 147          "\u1E15": "e",
 148          "\u1E1D": "e",
 149          "\u0207": "e",
 150          "\u1EBB": "e",
 151          "\u1EBD": "e",
 152          "\u1EB9": "e",
 153          "\u1EC3": "e",
 154          "\u1EC5": "e",
 155          "\u1EC7": "e",
 156          "\xEC": "i",
 157          "\xED": "i",
 158          "\xEE": "i",
 159          "\xEF": "i",
 160          "\u1E2F": "i",
 161          "\u020B": "i",
 162          "\u1EC9": "i",
 163          "\u1ECB": "i",
 164          "\xF0": "d",
 165          "\xF1": "n",
 166          "\xF2": "o",
 167          "\xF3": "o",
 168          "\xF4": "o",
 169          "\xF5": "o",
 170          "\xF6": "o",
 171          "\xF8": "o",
 172          "\u1ED1": "o",
 173          "\u1E4D": "o",
 174          "\u1E53": "o",
 175          "\u020F": "o",
 176          "\u1ECF": "o",
 177          "\u1ECD": "o",
 178          "\u1ED5": "o",
 179          "\u1ED7": "o",
 180          "\u1ED9": "o",
 181          "\u1EDD": "o",
 182          "\u1EDF": "o",
 183          "\u1EE1": "o",
 184          "\u1EDB": "o",
 185          "\u1EE3": "o",
 186          "\xF9": "u",
 187          "\xFA": "u",
 188          "\xFB": "u",
 189          "\xFC": "u",
 190          "\u1EE7": "u",
 191          "\u1EE5": "u",
 192          "\u1EED": "u",
 193          "\u1EEF": "u",
 194          "\u1EF1": "u",
 195          "\xFD": "y",
 196          "\xFF": "y",
 197          "\u0100": "A",
 198          "\u0101": "a",
 199          "\u0102": "A",
 200          "\u0103": "a",
 201          "\u0104": "A",
 202          "\u0105": "a",
 203          "\u0106": "C",
 204          "\u0107": "c",
 205          "\u0108": "C",
 206          "\u0109": "c",
 207          "\u010A": "C",
 208          "\u010B": "c",
 209          "\u010C": "C",
 210          "\u010D": "c",
 211          "C\u0306": "C",
 212          "c\u0306": "c",
 213          "\u010E": "D",
 214          "\u010F": "d",
 215          "\u0110": "D",
 216          "\u0111": "d",
 217          "\u0112": "E",
 218          "\u0113": "e",
 219          "\u0114": "E",
 220          "\u0115": "e",
 221          "\u0116": "E",
 222          "\u0117": "e",
 223          "\u0118": "E",
 224          "\u0119": "e",
 225          "\u011A": "E",
 226          "\u011B": "e",
 227          "\u011C": "G",
 228          "\u01F4": "G",
 229          "\u011D": "g",
 230          "\u01F5": "g",
 231          "\u011E": "G",
 232          "\u011F": "g",
 233          "\u0120": "G",
 234          "\u0121": "g",
 235          "\u0122": "G",
 236          "\u0123": "g",
 237          "\u0124": "H",
 238          "\u0125": "h",
 239          "\u0126": "H",
 240          "\u0127": "h",
 241          "\u1E2A": "H",
 242          "\u1E2B": "h",
 243          "\u0128": "I",
 244          "\u0129": "i",
 245          "\u012A": "I",
 246          "\u012B": "i",
 247          "\u012C": "I",
 248          "\u012D": "i",
 249          "\u012E": "I",
 250          "\u012F": "i",
 251          "\u0130": "I",
 252          "\u0131": "i",
 253          "\u0132": "IJ",
 254          "\u0133": "ij",
 255          "\u0134": "J",
 256          "\u0135": "j",
 257          "\u0136": "K",
 258          "\u0137": "k",
 259          "\u1E30": "K",
 260          "\u1E31": "k",
 261          "K\u0306": "K",
 262          "k\u0306": "k",
 263          "\u0139": "L",
 264          "\u013A": "l",
 265          "\u013B": "L",
 266          "\u013C": "l",
 267          "\u013D": "L",
 268          "\u013E": "l",
 269          "\u013F": "L",
 270          "\u0140": "l",
 271          "\u0141": "l",
 272          "\u0142": "l",
 273          "\u1E3E": "M",
 274          "\u1E3F": "m",
 275          "M\u0306": "M",
 276          "m\u0306": "m",
 277          "\u0143": "N",
 278          "\u0144": "n",
 279          "\u0145": "N",
 280          "\u0146": "n",
 281          "\u0147": "N",
 282          "\u0148": "n",
 283          "\u0149": "n",
 284          "N\u0306": "N",
 285          "n\u0306": "n",
 286          "\u014C": "O",
 287          "\u014D": "o",
 288          "\u014E": "O",
 289          "\u014F": "o",
 290          "\u0150": "O",
 291          "\u0151": "o",
 292          "\u0152": "OE",
 293          "\u0153": "oe",
 294          "P\u0306": "P",
 295          "p\u0306": "p",
 296          "\u0154": "R",
 297          "\u0155": "r",
 298          "\u0156": "R",
 299          "\u0157": "r",
 300          "\u0158": "R",
 301          "\u0159": "r",
 302          "R\u0306": "R",
 303          "r\u0306": "r",
 304          "\u0212": "R",
 305          "\u0213": "r",
 306          "\u015A": "S",
 307          "\u015B": "s",
 308          "\u015C": "S",
 309          "\u015D": "s",
 310          "\u015E": "S",
 311          "\u0218": "S",
 312          "\u0219": "s",
 313          "\u015F": "s",
 314          "\u0160": "S",
 315          "\u0161": "s",
 316          "\u0162": "T",
 317          "\u0163": "t",
 318          "\u021B": "t",
 319          "\u021A": "T",
 320          "\u0164": "T",
 321          "\u0165": "t",
 322          "\u0166": "T",
 323          "\u0167": "t",
 324          "T\u0306": "T",
 325          "t\u0306": "t",
 326          "\u0168": "U",
 327          "\u0169": "u",
 328          "\u016A": "U",
 329          "\u016B": "u",
 330          "\u016C": "U",
 331          "\u016D": "u",
 332          "\u016E": "U",
 333          "\u016F": "u",
 334          "\u0170": "U",
 335          "\u0171": "u",
 336          "\u0172": "U",
 337          "\u0173": "u",
 338          "\u0216": "U",
 339          "\u0217": "u",
 340          "V\u0306": "V",
 341          "v\u0306": "v",
 342          "\u0174": "W",
 343          "\u0175": "w",
 344          "\u1E82": "W",
 345          "\u1E83": "w",
 346          "X\u0306": "X",
 347          "x\u0306": "x",
 348          "\u0176": "Y",
 349          "\u0177": "y",
 350          "\u0178": "Y",
 351          "Y\u0306": "Y",
 352          "y\u0306": "y",
 353          "\u0179": "Z",
 354          "\u017A": "z",
 355          "\u017B": "Z",
 356          "\u017C": "z",
 357          "\u017D": "Z",
 358          "\u017E": "z",
 359          "\u017F": "s",
 360          "\u0192": "f",
 361          "\u01A0": "O",
 362          "\u01A1": "o",
 363          "\u01AF": "U",
 364          "\u01B0": "u",
 365          "\u01CD": "A",
 366          "\u01CE": "a",
 367          "\u01CF": "I",
 368          "\u01D0": "i",
 369          "\u01D1": "O",
 370          "\u01D2": "o",
 371          "\u01D3": "U",
 372          "\u01D4": "u",
 373          "\u01D5": "U",
 374          "\u01D6": "u",
 375          "\u01D7": "U",
 376          "\u01D8": "u",
 377          "\u01D9": "U",
 378          "\u01DA": "u",
 379          "\u01DB": "U",
 380          "\u01DC": "u",
 381          "\u1EE8": "U",
 382          "\u1EE9": "u",
 383          "\u1E78": "U",
 384          "\u1E79": "u",
 385          "\u01FA": "A",
 386          "\u01FB": "a",
 387          "\u01FC": "AE",
 388          "\u01FD": "ae",
 389          "\u01FE": "O",
 390          "\u01FF": "o",
 391          "\xDE": "TH",
 392          "\xFE": "th",
 393          "\u1E54": "P",
 394          "\u1E55": "p",
 395          "\u1E64": "S",
 396          "\u1E65": "s",
 397          "X\u0301": "X",
 398          "x\u0301": "x",
 399          "\u0403": "\u0413",
 400          "\u0453": "\u0433",
 401          "\u040C": "\u041A",
 402          "\u045C": "\u043A",
 403          "A\u030B": "A",
 404          "a\u030B": "a",
 405          "E\u030B": "E",
 406          "e\u030B": "e",
 407          "I\u030B": "I",
 408          "i\u030B": "i",
 409          "\u01F8": "N",
 410          "\u01F9": "n",
 411          "\u1ED2": "O",
 412          "\u1ED3": "o",
 413          "\u1E50": "O",
 414          "\u1E51": "o",
 415          "\u1EEA": "U",
 416          "\u1EEB": "u",
 417          "\u1E80": "W",
 418          "\u1E81": "w",
 419          "\u1EF2": "Y",
 420          "\u1EF3": "y",
 421          "\u0200": "A",
 422          "\u0201": "a",
 423          "\u0204": "E",
 424          "\u0205": "e",
 425          "\u0208": "I",
 426          "\u0209": "i",
 427          "\u020C": "O",
 428          "\u020D": "o",
 429          "\u0210": "R",
 430          "\u0211": "r",
 431          "\u0214": "U",
 432          "\u0215": "u",
 433          "B\u030C": "B",
 434          "b\u030C": "b",
 435          "\u010C\u0323": "C",
 436          "\u010D\u0323": "c",
 437          "\xCA\u030C": "E",
 438          "\xEA\u030C": "e",
 439          "F\u030C": "F",
 440          "f\u030C": "f",
 441          "\u01E6": "G",
 442          "\u01E7": "g",
 443          "\u021E": "H",
 444          "\u021F": "h",
 445          "J\u030C": "J",
 446          "\u01F0": "j",
 447          "\u01E8": "K",
 448          "\u01E9": "k",
 449          "M\u030C": "M",
 450          "m\u030C": "m",
 451          "P\u030C": "P",
 452          "p\u030C": "p",
 453          "Q\u030C": "Q",
 454          "q\u030C": "q",
 455          "\u0158\u0329": "R",
 456          "\u0159\u0329": "r",
 457          "\u1E66": "S",
 458          "\u1E67": "s",
 459          "V\u030C": "V",
 460          "v\u030C": "v",
 461          "W\u030C": "W",
 462          "w\u030C": "w",
 463          "X\u030C": "X",
 464          "x\u030C": "x",
 465          "Y\u030C": "Y",
 466          "y\u030C": "y",
 467          "A\u0327": "A",
 468          "a\u0327": "a",
 469          "B\u0327": "B",
 470          "b\u0327": "b",
 471          "\u1E10": "D",
 472          "\u1E11": "d",
 473          "\u0228": "E",
 474          "\u0229": "e",
 475          "\u0190\u0327": "E",
 476          "\u025B\u0327": "e",
 477          "\u1E28": "H",
 478          "\u1E29": "h",
 479          "I\u0327": "I",
 480          "i\u0327": "i",
 481          "\u0197\u0327": "I",
 482          "\u0268\u0327": "i",
 483          "M\u0327": "M",
 484          "m\u0327": "m",
 485          "O\u0327": "O",
 486          "o\u0327": "o",
 487          "Q\u0327": "Q",
 488          "q\u0327": "q",
 489          "U\u0327": "U",
 490          "u\u0327": "u",
 491          "X\u0327": "X",
 492          "x\u0327": "x",
 493          "Z\u0327": "Z",
 494          "z\u0327": "z",
 495          "\u0439": "\u0438",
 496          "\u0419": "\u0418",
 497          "\u0451": "\u0435",
 498          "\u0401": "\u0415"
 499        };
 500        var chars = Object.keys(characterMap).join("|");
 501        var allAccents = new RegExp(chars, "g");
 502        var firstAccent = new RegExp(chars, "");
 503        function matcher(match) {
 504          return characterMap[match];
 505        }
 506        var removeAccents2 = function(string) {
 507          return string.replace(allAccents, matcher);
 508        };
 509        var hasAccents = function(string) {
 510          return !!string.match(firstAccent);
 511        };
 512        module.exports = removeAccents2;
 513        module.exports.has = hasAccents;
 514        module.exports.remove = removeAccents2;
 515      }
 516    });
 517  
 518    // packages/url/build-module/index.mjs
 519    var index_exports = {};
 520    __export(index_exports, {
 521      addQueryArgs: () => addQueryArgs,
 522      buildQueryString: () => buildQueryString,
 523      cleanForSlug: () => cleanForSlug,
 524      filterURLForDisplay: () => filterURLForDisplay,
 525      getAuthority: () => getAuthority,
 526      getFilename: () => getFilename,
 527      getFragment: () => getFragment,
 528      getPath: () => getPath,
 529      getPathAndQueryString: () => getPathAndQueryString,
 530      getProtocol: () => getProtocol,
 531      getQueryArg: () => getQueryArg,
 532      getQueryArgs: () => getQueryArgs,
 533      getQueryString: () => getQueryString,
 534      hasQueryArg: () => hasQueryArg,
 535      isEmail: () => isEmail,
 536      isPhoneNumber: () => isPhoneNumber,
 537      isURL: () => isURL,
 538      isValidAuthority: () => isValidAuthority,
 539      isValidFragment: () => isValidFragment,
 540      isValidPath: () => isValidPath,
 541      isValidProtocol: () => isValidProtocol,
 542      isValidQueryString: () => isValidQueryString,
 543      normalizePath: () => normalizePath,
 544      prependHTTP: () => prependHTTP,
 545      prependHTTPS: () => prependHTTPS,
 546      removeQueryArgs: () => removeQueryArgs,
 547      safeDecodeURI: () => safeDecodeURI,
 548      safeDecodeURIComponent: () => safeDecodeURIComponent
 549    });
 550  
 551    // packages/url/build-module/is-url.mjs
 552    function isURL(url) {
 553      try {
 554        new URL(url);
 555        return true;
 556      } catch {
 557        return false;
 558      }
 559    }
 560  
 561    // packages/url/build-module/is-email.mjs
 562    var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
 563    function isEmail(email) {
 564      return EMAIL_REGEXP.test(email);
 565    }
 566  
 567    // packages/url/build-module/is-phone-number.mjs
 568    var PHONE_REGEXP = /^(tel:)?(\+)?\d{6,15}$/;
 569    function isPhoneNumber(phoneNumber) {
 570      phoneNumber = phoneNumber.replace(/[-.() ]/g, "");
 571      return PHONE_REGEXP.test(phoneNumber);
 572    }
 573  
 574    // packages/url/build-module/get-protocol.mjs
 575    function getProtocol(url) {
 576      const matches = /^([^\s:]+:)/.exec(url);
 577      if (matches) {
 578        return matches[1];
 579      }
 580    }
 581  
 582    // packages/url/build-module/is-valid-protocol.mjs
 583    function isValidProtocol(protocol) {
 584      if (!protocol) {
 585        return false;
 586      }
 587      return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol);
 588    }
 589  
 590    // packages/url/build-module/get-authority.mjs
 591    function getAuthority(url) {
 592      const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(
 593        url
 594      );
 595      if (matches) {
 596        return matches[1];
 597      }
 598    }
 599  
 600    // packages/url/build-module/is-valid-authority.mjs
 601    function isValidAuthority(authority) {
 602      if (!authority) {
 603        return false;
 604      }
 605      return /^[^\s#?]+$/.test(authority);
 606    }
 607  
 608    // packages/url/build-module/get-path.mjs
 609    function getPath(url) {
 610      const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
 611      if (matches) {
 612        return matches[1];
 613      }
 614    }
 615  
 616    // packages/url/build-module/is-valid-path.mjs
 617    function isValidPath(path) {
 618      if (!path) {
 619        return false;
 620      }
 621      return /^[^\s#?]+$/.test(path);
 622    }
 623  
 624    // packages/url/build-module/get-query-string.mjs
 625    function getQueryString(url) {
 626      let query;
 627      try {
 628        query = new URL(url, "http://example.com").search.substring(1);
 629      } catch {
 630      }
 631      if (query) {
 632        return query;
 633      }
 634    }
 635  
 636    // packages/url/build-module/build-query-string.mjs
 637    function buildQueryString(data) {
 638      let string = "";
 639      const stack = Object.entries(data);
 640      let pair;
 641      while (pair = stack.shift()) {
 642        let [key, value] = pair;
 643        const hasNestedData = Array.isArray(value) || value && value.constructor === Object;
 644        if (hasNestedData) {
 645          const valuePairs = Object.entries(value).reverse();
 646          for (const [member, memberValue] of valuePairs) {
 647            stack.unshift([`$key}[$member}]`, memberValue]);
 648          }
 649        } else if (value !== void 0) {
 650          if (value === null) {
 651            value = "";
 652          }
 653          string += "&" + [key, String(value)].map(encodeURIComponent).join("=");
 654        }
 655      }
 656      return string.substr(1);
 657    }
 658  
 659    // packages/url/build-module/is-valid-query-string.mjs
 660    function isValidQueryString(queryString) {
 661      if (!queryString) {
 662        return false;
 663      }
 664      return /^[^\s#?\/]+$/.test(queryString);
 665    }
 666  
 667    // packages/url/build-module/get-path-and-query-string.mjs
 668    function getPathAndQueryString(url) {
 669      const path = getPath(url);
 670      const queryString = getQueryString(url);
 671      let value = "/";
 672      if (path) {
 673        value += path;
 674      }
 675      if (queryString) {
 676        value += `?$queryString}`;
 677      }
 678      return value;
 679    }
 680  
 681    // packages/url/build-module/get-fragment.mjs
 682    function getFragment(url) {
 683      const matches = /^\S+?(#[^\s\?]*)/.exec(url);
 684      if (matches) {
 685        return matches[1];
 686      }
 687    }
 688  
 689    // packages/url/build-module/is-valid-fragment.mjs
 690    function isValidFragment(fragment) {
 691      if (!fragment) {
 692        return false;
 693      }
 694      return /^#[^\s#?\/]*$/.test(fragment);
 695    }
 696  
 697    // packages/url/build-module/safe-decode-uri-component.mjs
 698    function safeDecodeURIComponent(uriComponent) {
 699      try {
 700        return decodeURIComponent(uriComponent);
 701      } catch {
 702        return uriComponent;
 703      }
 704    }
 705  
 706    // packages/url/build-module/get-query-args.mjs
 707    function setPath(object, path, value) {
 708      const length = path.length;
 709      const lastIndex = length - 1;
 710      for (let i = 0; i < length; i++) {
 711        let key = path[i];
 712        if (!key && Array.isArray(object)) {
 713          key = object.length.toString();
 714        }
 715        key = ["__proto__", "constructor", "prototype"].includes(key) ? key.toUpperCase() : key;
 716        const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
 717        object[key] = i === lastIndex ? (
 718          // If at end of path, assign the intended value.
 719          value
 720        ) : (
 721          // Otherwise, advance to the next object in the path, creating
 722          // it if it does not yet exist.
 723          object[key] || (isNextKeyArrayIndex ? [] : {})
 724        );
 725        if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
 726          object[key] = { ...object[key] };
 727        }
 728        object = object[key];
 729      }
 730    }
 731    function getQueryArgs(url) {
 732      return (getQueryString(url) || "").replace(/\+/g, "%20").split("&").reduce((accumulator, keyValue) => {
 733        const [key, value = ""] = keyValue.split("=").filter(Boolean).map(safeDecodeURIComponent);
 734        if (key) {
 735          const segments = key.replace(/\]/g, "").split("[");
 736          setPath(accumulator, segments, value);
 737        }
 738        return accumulator;
 739      }, /* @__PURE__ */ Object.create(null));
 740    }
 741  
 742    // packages/url/build-module/add-query-args.mjs
 743    function addQueryArgs(url = "", args) {
 744      if (!args || !Object.keys(args).length) {
 745        return url;
 746      }
 747      const fragment = getFragment(url) || "";
 748      let baseUrl = url.replace(fragment, "");
 749      const queryStringIndex = url.indexOf("?");
 750      if (queryStringIndex !== -1) {
 751        args = Object.assign(getQueryArgs(url), args);
 752        baseUrl = baseUrl.substr(0, queryStringIndex);
 753      }
 754      return baseUrl + "?" + buildQueryString(args) + fragment;
 755    }
 756  
 757    // packages/url/build-module/get-query-arg.mjs
 758    function getQueryArg(url, arg) {
 759      return getQueryArgs(url)[arg];
 760    }
 761  
 762    // packages/url/build-module/has-query-arg.mjs
 763    function hasQueryArg(url, arg) {
 764      return getQueryArg(url, arg) !== void 0;
 765    }
 766  
 767    // packages/url/build-module/remove-query-args.mjs
 768    function removeQueryArgs(url, ...args) {
 769      const fragment = url.replace(/^[^#]*/, "");
 770      url = url.replace(/#.*/, "");
 771      const queryStringIndex = url.indexOf("?");
 772      if (queryStringIndex === -1) {
 773        return url + fragment;
 774      }
 775      const query = getQueryArgs(url);
 776      const baseURL = url.substr(0, queryStringIndex);
 777      args.forEach((arg) => delete query[arg]);
 778      const queryString = buildQueryString(query);
 779      const updatedUrl = queryString ? baseURL + "?" + queryString : baseURL;
 780      return updatedUrl + fragment;
 781    }
 782  
 783    // packages/url/build-module/prepend-http.mjs
 784    var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
 785    function prependHTTP(url) {
 786      if (!url) {
 787        return url;
 788      }
 789      url = url.trim();
 790      if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
 791        return "http://" + url;
 792      }
 793      return url;
 794    }
 795  
 796    // packages/url/build-module/safe-decode-uri.mjs
 797    function safeDecodeURI(uri) {
 798      try {
 799        return decodeURI(uri);
 800      } catch {
 801        return uri;
 802      }
 803    }
 804  
 805    // packages/url/build-module/filter-url-for-display.mjs
 806    function filterURLForDisplay(url, maxLength = null) {
 807      if (!url) {
 808        return "";
 809      }
 810      let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, "").replace(/^www\./i, "");
 811      if (filteredURL.match(/^[^\/]+\/$/)) {
 812        filteredURL = filteredURL.replace("/", "");
 813      }
 814      const fileRegexp = /\/([^\/?]+)\.(?:[\w]+)(?=\?|$)/;
 815      if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(fileRegexp)) {
 816        return filteredURL;
 817      }
 818      filteredURL = filteredURL.split("?")[0];
 819      const urlPieces = filteredURL.split("/");
 820      const file = urlPieces[urlPieces.length - 1];
 821      if (file.length <= maxLength) {
 822        return "\u2026" + filteredURL.slice(-maxLength);
 823      }
 824      const index = file.lastIndexOf(".");
 825      const [fileName, extension] = [
 826        file.slice(0, index),
 827        file.slice(index + 1)
 828      ];
 829      const truncatedFile = fileName.slice(-3) + "." + extension;
 830      return file.slice(0, maxLength - truncatedFile.length - 1) + "\u2026" + truncatedFile;
 831    }
 832  
 833    // packages/url/build-module/clean-for-slug.mjs
 834    var import_remove_accents = __toESM(require_remove_accents(), 1);
 835    function cleanForSlug(string) {
 836      if (!string) {
 837        return "";
 838      }
 839      return (0, import_remove_accents.default)(string).replace(/(&nbsp;|&ndash;|&mdash;)/g, "-").replace(/[\s\./]+/g, "-").replace(/&\S+?;/g, "").replace(/[^\p{L}\p{N}_-]+/gu, "").toLowerCase().replace(/-+/g, "-").replace(/(^-+)|(-+$)/g, "");
 840    }
 841  
 842    // packages/url/build-module/get-filename.mjs
 843    function getFilename(url) {
 844      let filename;
 845      if (!url) {
 846        return;
 847      }
 848      try {
 849        filename = new URL(url, "http://example.com").pathname.split("/").pop();
 850      } catch {
 851      }
 852      if (filename) {
 853        return filename;
 854      }
 855    }
 856  
 857    // packages/url/build-module/normalize-path.mjs
 858    function normalizePath(path) {
 859      const split = path.split("?");
 860      const query = split[1];
 861      const base = split[0];
 862      if (!query) {
 863        return base;
 864      }
 865      return base + "?" + query.split("&").map((entry) => entry.split("=")).map((pair) => pair.map(decodeURIComponent)).sort((a, b) => a[0].localeCompare(b[0])).map((pair) => pair.map(encodeURIComponent)).map((pair) => pair.join("=")).join("&");
 866    }
 867  
 868    // packages/url/build-module/prepend-https.mjs
 869    function prependHTTPS(url) {
 870      if (!url) {
 871        return url;
 872      }
 873      if (url.startsWith("http://")) {
 874        return url;
 875      }
 876      url = prependHTTP(url);
 877      return url.replace(/^http:/, "https:");
 878    }
 879    return __toCommonJS(index_exports);
 880  })();
 881  (window.wp ||= {}).url = wp.url;
 882  })();


Generated : Wed Aug 26 08:20:24 2026 Cross-referenced by PHPXref