[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 this["wp"] = this["wp"] || {}; this["wp"]["url"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = 338); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ 214: 91 /***/ (function(module, exports, __webpack_require__) { 92 93 "use strict"; 94 95 96 var has = Object.prototype.hasOwnProperty; 97 var isArray = Array.isArray; 98 99 var hexTable = (function () { 100 var array = []; 101 for (var i = 0; i < 256; ++i) { 102 array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); 103 } 104 105 return array; 106 }()); 107 108 var compactQueue = function compactQueue(queue) { 109 while (queue.length > 1) { 110 var item = queue.pop(); 111 var obj = item.obj[item.prop]; 112 113 if (isArray(obj)) { 114 var compacted = []; 115 116 for (var j = 0; j < obj.length; ++j) { 117 if (typeof obj[j] !== 'undefined') { 118 compacted.push(obj[j]); 119 } 120 } 121 122 item.obj[item.prop] = compacted; 123 } 124 } 125 }; 126 127 var arrayToObject = function arrayToObject(source, options) { 128 var obj = options && options.plainObjects ? Object.create(null) : {}; 129 for (var i = 0; i < source.length; ++i) { 130 if (typeof source[i] !== 'undefined') { 131 obj[i] = source[i]; 132 } 133 } 134 135 return obj; 136 }; 137 138 var merge = function merge(target, source, options) { 139 if (!source) { 140 return target; 141 } 142 143 if (typeof source !== 'object') { 144 if (isArray(target)) { 145 target.push(source); 146 } else if (target && typeof target === 'object') { 147 if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { 148 target[source] = true; 149 } 150 } else { 151 return [target, source]; 152 } 153 154 return target; 155 } 156 157 if (!target || typeof target !== 'object') { 158 return [target].concat(source); 159 } 160 161 var mergeTarget = target; 162 if (isArray(target) && !isArray(source)) { 163 mergeTarget = arrayToObject(target, options); 164 } 165 166 if (isArray(target) && isArray(source)) { 167 source.forEach(function (item, i) { 168 if (has.call(target, i)) { 169 var targetItem = target[i]; 170 if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { 171 target[i] = merge(targetItem, item, options); 172 } else { 173 target.push(item); 174 } 175 } else { 176 target[i] = item; 177 } 178 }); 179 return target; 180 } 181 182 return Object.keys(source).reduce(function (acc, key) { 183 var value = source[key]; 184 185 if (has.call(acc, key)) { 186 acc[key] = merge(acc[key], value, options); 187 } else { 188 acc[key] = value; 189 } 190 return acc; 191 }, mergeTarget); 192 }; 193 194 var assign = function assignSingleSource(target, source) { 195 return Object.keys(source).reduce(function (acc, key) { 196 acc[key] = source[key]; 197 return acc; 198 }, target); 199 }; 200 201 var decode = function (str, decoder, charset) { 202 var strWithoutPlus = str.replace(/\+/g, ' '); 203 if (charset === 'iso-8859-1') { 204 // unescape never throws, no try...catch needed: 205 return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); 206 } 207 // utf-8 208 try { 209 return decodeURIComponent(strWithoutPlus); 210 } catch (e) { 211 return strWithoutPlus; 212 } 213 }; 214 215 var encode = function encode(str, defaultEncoder, charset) { 216 // This code was originally written by Brian White (mscdex) for the io.js core querystring library. 217 // It has been adapted here for stricter adherence to RFC 3986 218 if (str.length === 0) { 219 return str; 220 } 221 222 var string = typeof str === 'string' ? str : String(str); 223 224 if (charset === 'iso-8859-1') { 225 return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { 226 return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; 227 }); 228 } 229 230 var out = ''; 231 for (var i = 0; i < string.length; ++i) { 232 var c = string.charCodeAt(i); 233 234 if ( 235 c === 0x2D // - 236 || c === 0x2E // . 237 || c === 0x5F // _ 238 || c === 0x7E // ~ 239 || (c >= 0x30 && c <= 0x39) // 0-9 240 || (c >= 0x41 && c <= 0x5A) // a-z 241 || (c >= 0x61 && c <= 0x7A) // A-Z 242 ) { 243 out += string.charAt(i); 244 continue; 245 } 246 247 if (c < 0x80) { 248 out = out + hexTable[c]; 249 continue; 250 } 251 252 if (c < 0x800) { 253 out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); 254 continue; 255 } 256 257 if (c < 0xD800 || c >= 0xE000) { 258 out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); 259 continue; 260 } 261 262 i += 1; 263 c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); 264 out += hexTable[0xF0 | (c >> 18)] 265 + hexTable[0x80 | ((c >> 12) & 0x3F)] 266 + hexTable[0x80 | ((c >> 6) & 0x3F)] 267 + hexTable[0x80 | (c & 0x3F)]; 268 } 269 270 return out; 271 }; 272 273 var compact = function compact(value) { 274 var queue = [{ obj: { o: value }, prop: 'o' }]; 275 var refs = []; 276 277 for (var i = 0; i < queue.length; ++i) { 278 var item = queue[i]; 279 var obj = item.obj[item.prop]; 280 281 var keys = Object.keys(obj); 282 for (var j = 0; j < keys.length; ++j) { 283 var key = keys[j]; 284 var val = obj[key]; 285 if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { 286 queue.push({ obj: obj, prop: key }); 287 refs.push(val); 288 } 289 } 290 } 291 292 compactQueue(queue); 293 294 return value; 295 }; 296 297 var isRegExp = function isRegExp(obj) { 298 return Object.prototype.toString.call(obj) === '[object RegExp]'; 299 }; 300 301 var isBuffer = function isBuffer(obj) { 302 if (!obj || typeof obj !== 'object') { 303 return false; 304 } 305 306 return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); 307 }; 308 309 var combine = function combine(a, b) { 310 return [].concat(a, b); 311 }; 312 313 module.exports = { 314 arrayToObject: arrayToObject, 315 assign: assign, 316 combine: combine, 317 compact: compact, 318 decode: decode, 319 encode: encode, 320 isBuffer: isBuffer, 321 isRegExp: isRegExp, 322 merge: merge 323 }; 324 325 326 /***/ }), 327 328 /***/ 215: 329 /***/ (function(module, exports, __webpack_require__) { 330 331 "use strict"; 332 333 334 var replace = String.prototype.replace; 335 var percentTwenties = /%20/g; 336 337 module.exports = { 338 'default': 'RFC3986', 339 formatters: { 340 RFC1738: function (value) { 341 return replace.call(value, percentTwenties, '+'); 342 }, 343 RFC3986: function (value) { 344 return value; 345 } 346 }, 347 RFC1738: 'RFC1738', 348 RFC3986: 'RFC3986' 349 }; 350 351 352 /***/ }), 353 354 /***/ 338: 355 /***/ (function(module, __webpack_exports__, __webpack_require__) { 356 357 "use strict"; 358 __webpack_require__.r(__webpack_exports__); 359 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isURL", function() { return isURL; }); 360 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isEmail", function() { return isEmail; }); 361 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getProtocol", function() { return getProtocol; }); 362 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return isValidProtocol; }); 363 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAuthority", function() { return getAuthority; }); 364 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return isValidAuthority; }); 365 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPath", function() { return getPath; }); 366 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidPath", function() { return isValidPath; }); 367 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryString", function() { return getQueryString; }); 368 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return isValidQueryString; }); 369 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFragment", function() { return getFragment; }); 370 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return isValidFragment; }); 371 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return addQueryArgs; }); 372 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return getQueryArg; }); 373 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return hasQueryArg; }); 374 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return removeQueryArgs; }); 375 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return prependHTTP; }); 376 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return safeDecodeURI; }); 377 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return filterURLForDisplay; }); 378 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURIComponent", function() { return safeDecodeURIComponent; }); 379 /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(84); 380 /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_0__); 381 /** 382 * External dependencies 383 */ 384 385 var URL_REGEXP = /^(?:https?:)?\/\/\S+$/i; 386 var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; 387 var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; 388 /** 389 * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject 390 */ 391 392 /** 393 * @typedef {string|string[]|QueryArgObject} QueryArgParsed 394 */ 395 396 /** 397 * Determines whether the given string looks like a URL. 398 * 399 * @param {string} url The string to scrutinise. 400 * 401 * @example 402 * ```js 403 * const isURL = isURL( 'https://wordpress.org' ); // true 404 * ``` 405 * 406 * @return {boolean} Whether or not it looks like a URL. 407 */ 408 409 function isURL(url) { 410 return URL_REGEXP.test(url); 411 } 412 /** 413 * Determines whether the given string looks like an email. 414 * 415 * @param {string} email The string to scrutinise. 416 * 417 * @example 418 * ```js 419 * const isEmail = isEmail( 'hello@wordpress.org' ); // true 420 * ``` 421 * 422 * @return {boolean} Whether or not it looks like an email. 423 */ 424 425 function isEmail(email) { 426 return EMAIL_REGEXP.test(email); 427 } 428 /** 429 * Returns the protocol part of the URL. 430 * 431 * @param {string} url The full URL. 432 * 433 * @example 434 * ```js 435 * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' 436 * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' 437 * ``` 438 * 439 * @return {string|void} The protocol part of the URL. 440 */ 441 442 function getProtocol(url) { 443 var matches = /^([^\s:]+:)/.exec(url); 444 445 if (matches) { 446 return matches[1]; 447 } 448 } 449 /** 450 * Tests if a url protocol is valid. 451 * 452 * @param {string} protocol The url protocol. 453 * 454 * @example 455 * ```js 456 * const isValid = isValidProtocol( 'https:' ); // true 457 * const isNotValid = isValidProtocol( 'https :' ); // false 458 * ``` 459 * 460 * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). 461 */ 462 463 function isValidProtocol(protocol) { 464 if (!protocol) { 465 return false; 466 } 467 468 return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); 469 } 470 /** 471 * Returns the authority part of the URL. 472 * 473 * @param {string} url The full URL. 474 * 475 * @example 476 * ```js 477 * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' 478 * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' 479 * ``` 480 * 481 * @return {string|void} The authority part of the URL. 482 */ 483 484 function getAuthority(url) { 485 var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); 486 487 if (matches) { 488 return matches[1]; 489 } 490 } 491 /** 492 * Checks for invalid characters within the provided authority. 493 * 494 * @param {string} authority A string containing the URL authority. 495 * 496 * @example 497 * ```js 498 * const isValid = isValidAuthority( 'wordpress.org' ); // true 499 * const isNotValid = isValidAuthority( 'wordpress#org' ); // false 500 * ``` 501 * 502 * @return {boolean} True if the argument contains a valid authority. 503 */ 504 505 function isValidAuthority(authority) { 506 if (!authority) { 507 return false; 508 } 509 510 return /^[^\s#?]+$/.test(authority); 511 } 512 /** 513 * Returns the path part of the URL. 514 * 515 * @param {string} url The full URL. 516 * 517 * @example 518 * ```js 519 * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' 520 * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' 521 * ``` 522 * 523 * @return {string|void} The path part of the URL. 524 */ 525 526 function getPath(url) { 527 var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); 528 529 if (matches) { 530 return matches[1]; 531 } 532 } 533 /** 534 * Checks for invalid characters within the provided path. 535 * 536 * @param {string} path The URL path. 537 * 538 * @example 539 * ```js 540 * const isValid = isValidPath( 'test/path/' ); // true 541 * const isNotValid = isValidPath( '/invalid?test/path/' ); // false 542 * ``` 543 * 544 * @return {boolean} True if the argument contains a valid path 545 */ 546 547 function isValidPath(path) { 548 if (!path) { 549 return false; 550 } 551 552 return /^[^\s#?]+$/.test(path); 553 } 554 /** 555 * Returns the query string part of the URL. 556 * 557 * @param {string} url The full URL. 558 * 559 * @example 560 * ```js 561 * const queryString1 = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' 562 * const queryString2 = getQueryString( 'https://wordpress.org#fragment?query=false&search=hello' ); // 'query=false&search=hello' 563 * ``` 564 * 565 * @return {string|void} The query string part of the URL. 566 */ 567 568 function getQueryString(url) { 569 var matches = /^\S+?\?([^\s#]+)/.exec(url); 570 571 if (matches) { 572 return matches[1]; 573 } 574 } 575 /** 576 * Checks for invalid characters within the provided query string. 577 * 578 * @param {string} queryString The query string. 579 * 580 * @example 581 * ```js 582 * const isValid = isValidQueryString( 'query=true&another=false' ); // true 583 * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false 584 * ``` 585 * 586 * @return {boolean} True if the argument contains a valid query string. 587 */ 588 589 function isValidQueryString(queryString) { 590 if (!queryString) { 591 return false; 592 } 593 594 return /^[^\s#?\/]+$/.test(queryString); 595 } 596 /** 597 * Returns the fragment part of the URL. 598 * 599 * @param {string} url The full URL 600 * 601 * @example 602 * ```js 603 * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' 604 * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' 605 * ``` 606 * 607 * @return {string|void} The fragment part of the URL. 608 */ 609 610 function getFragment(url) { 611 var matches = /^\S+?(#[^\s\?]*)/.exec(url); 612 613 if (matches) { 614 return matches[1]; 615 } 616 } 617 /** 618 * Checks for invalid characters within the provided fragment. 619 * 620 * @param {string} fragment The url fragment. 621 * 622 * @example 623 * ```js 624 * const isValid = isValidFragment( '#valid-fragment' ); // true 625 * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false 626 * ``` 627 * 628 * @return {boolean} True if the argument contains a valid fragment. 629 */ 630 631 function isValidFragment(fragment) { 632 if (!fragment) { 633 return false; 634 } 635 636 return /^#[^\s#?\/]*$/.test(fragment); 637 } 638 /** 639 * Appends arguments as querystring to the provided URL. If the URL already 640 * includes query arguments, the arguments are merged with (and take precedent 641 * over) the existing set. 642 * 643 * @param {string} [url=''] URL to which arguments should be appended. If omitted, 644 * only the resulting querystring is returned. 645 * @param {Object} args Query arguments to apply to URL. 646 * 647 * @example 648 * ```js 649 * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test 650 * ``` 651 * 652 * @return {string} URL with arguments applied. 653 */ 654 655 function addQueryArgs() { 656 var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; 657 var args = arguments.length > 1 ? arguments[1] : undefined; 658 659 // If no arguments are to be appended, return original URL. 660 if (!args || !Object.keys(args).length) { 661 return url; 662 } 663 664 var baseUrl = url; // Determine whether URL already had query arguments. 665 666 var queryStringIndex = url.indexOf('?'); 667 668 if (queryStringIndex !== -1) { 669 // Merge into existing query arguments. 670 args = Object.assign(Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)), args); // Change working base URL to omit previous query arguments. 671 672 baseUrl = baseUrl.substr(0, queryStringIndex); 673 } 674 675 return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(args); 676 } 677 /** 678 * Returns a single query argument of the url 679 * 680 * @param {string} url URL. 681 * @param {string} arg Query arg name. 682 * 683 * @example 684 * ```js 685 * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar 686 * ``` 687 * 688 * @return {QueryArgParsed|undefined} Query arg value. 689 */ 690 691 function getQueryArg(url, arg) { 692 var queryStringIndex = url.indexOf('?'); 693 var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {}; 694 return query[arg]; 695 } 696 /** 697 * Determines whether the URL contains a given query arg. 698 * 699 * @param {string} url URL. 700 * @param {string} arg Query arg name. 701 * 702 * @example 703 * ```js 704 * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true 705 * ``` 706 * 707 * @return {boolean} Whether or not the URL contains the query arg. 708 */ 709 710 function hasQueryArg(url, arg) { 711 return getQueryArg(url, arg) !== undefined; 712 } 713 /** 714 * Removes arguments from the query string of the url 715 * 716 * @param {string} url URL. 717 * @param {...string} args Query Args. 718 * 719 * @example 720 * ```js 721 * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar 722 * ``` 723 * 724 * @return {string} Updated URL. 725 */ 726 727 function removeQueryArgs(url) { 728 var queryStringIndex = url.indexOf('?'); 729 var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {}; 730 var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; 731 732 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 733 args[_key - 1] = arguments[_key]; 734 } 735 736 args.forEach(function (arg) { 737 return delete query[arg]; 738 }); 739 return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(query); 740 } 741 /** 742 * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. 743 * 744 * @param {string} url The URL to test. 745 * 746 * @example 747 * ```js 748 * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org 749 * ``` 750 * 751 * @return {string} The updated URL. 752 */ 753 754 function prependHTTP(url) { 755 if (!url) { 756 return url; 757 } 758 759 url = url.trim(); 760 761 if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) { 762 return 'http://' + url; 763 } 764 765 return url; 766 } 767 /** 768 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if 769 * `decodeURI` throws an error. 770 * 771 * @param {string} uri URI to decode. 772 * 773 * @example 774 * ```js 775 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' 776 * ``` 777 * 778 * @return {string} Decoded URI if possible. 779 */ 780 781 function safeDecodeURI(uri) { 782 try { 783 return decodeURI(uri); 784 } catch (uriError) { 785 return uri; 786 } 787 } 788 /** 789 * Returns a URL for display. 790 * 791 * @param {string} url Original URL. 792 * 793 * @example 794 * ```js 795 * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg 796 * ``` 797 * 798 * @return {string} Displayed URL. 799 */ 800 801 function filterURLForDisplay(url) { 802 // Remove protocol and www prefixes. 803 var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. 804 805 if (filteredURL.match(/^[^\/]+\/$/)) { 806 return filteredURL.replace('/', ''); 807 } 808 809 return filteredURL; 810 } 811 /** 812 * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if 813 * `decodeURIComponent` throws an error. 814 * 815 * @param {string} uriComponent URI component to decode. 816 * 817 * @return {string} Decoded URI component if possible. 818 */ 819 820 function safeDecodeURIComponent(uriComponent) { 821 try { 822 return decodeURIComponent(uriComponent); 823 } catch (uriComponentError) { 824 return uriComponent; 825 } 826 } 827 828 829 /***/ }), 830 831 /***/ 339: 832 /***/ (function(module, exports, __webpack_require__) { 833 834 "use strict"; 835 836 837 var utils = __webpack_require__(214); 838 var formats = __webpack_require__(215); 839 var has = Object.prototype.hasOwnProperty; 840 841 var arrayPrefixGenerators = { 842 brackets: function brackets(prefix) { // eslint-disable-line func-name-matching 843 return prefix + '[]'; 844 }, 845 comma: 'comma', 846 indices: function indices(prefix, key) { // eslint-disable-line func-name-matching 847 return prefix + '[' + key + ']'; 848 }, 849 repeat: function repeat(prefix) { // eslint-disable-line func-name-matching 850 return prefix; 851 } 852 }; 853 854 var isArray = Array.isArray; 855 var push = Array.prototype.push; 856 var pushToArray = function (arr, valueOrArray) { 857 push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); 858 }; 859 860 var toISO = Date.prototype.toISOString; 861 862 var defaults = { 863 addQueryPrefix: false, 864 allowDots: false, 865 charset: 'utf-8', 866 charsetSentinel: false, 867 delimiter: '&', 868 encode: true, 869 encoder: utils.encode, 870 encodeValuesOnly: false, 871 formatter: formats.formatters[formats['default']], 872 // deprecated 873 indices: false, 874 serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching 875 return toISO.call(date); 876 }, 877 skipNulls: false, 878 strictNullHandling: false 879 }; 880 881 var stringify = function stringify( // eslint-disable-line func-name-matching 882 object, 883 prefix, 884 generateArrayPrefix, 885 strictNullHandling, 886 skipNulls, 887 encoder, 888 filter, 889 sort, 890 allowDots, 891 serializeDate, 892 formatter, 893 encodeValuesOnly, 894 charset 895 ) { 896 var obj = object; 897 if (typeof filter === 'function') { 898 obj = filter(prefix, obj); 899 } else if (obj instanceof Date) { 900 obj = serializeDate(obj); 901 } else if (generateArrayPrefix === 'comma' && isArray(obj)) { 902 obj = obj.join(','); 903 } 904 905 if (obj === null) { 906 if (strictNullHandling) { 907 return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset) : prefix; 908 } 909 910 obj = ''; 911 } 912 913 if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { 914 if (encoder) { 915 var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset); 916 return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))]; 917 } 918 return [formatter(prefix) + '=' + formatter(String(obj))]; 919 } 920 921 var values = []; 922 923 if (typeof obj === 'undefined') { 924 return values; 925 } 926 927 var objKeys; 928 if (isArray(filter)) { 929 objKeys = filter; 930 } else { 931 var keys = Object.keys(obj); 932 objKeys = sort ? keys.sort(sort) : keys; 933 } 934 935 for (var i = 0; i < objKeys.length; ++i) { 936 var key = objKeys[i]; 937 938 if (skipNulls && obj[key] === null) { 939 continue; 940 } 941 942 if (isArray(obj)) { 943 pushToArray(values, stringify( 944 obj[key], 945 typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix, 946 generateArrayPrefix, 947 strictNullHandling, 948 skipNulls, 949 encoder, 950 filter, 951 sort, 952 allowDots, 953 serializeDate, 954 formatter, 955 encodeValuesOnly, 956 charset 957 )); 958 } else { 959 pushToArray(values, stringify( 960 obj[key], 961 prefix + (allowDots ? '.' + key : '[' + key + ']'), 962 generateArrayPrefix, 963 strictNullHandling, 964 skipNulls, 965 encoder, 966 filter, 967 sort, 968 allowDots, 969 serializeDate, 970 formatter, 971 encodeValuesOnly, 972 charset 973 )); 974 } 975 } 976 977 return values; 978 }; 979 980 var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { 981 if (!opts) { 982 return defaults; 983 } 984 985 if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { 986 throw new TypeError('Encoder has to be a function.'); 987 } 988 989 var charset = opts.charset || defaults.charset; 990 if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { 991 throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); 992 } 993 994 var format = formats['default']; 995 if (typeof opts.format !== 'undefined') { 996 if (!has.call(formats.formatters, opts.format)) { 997 throw new TypeError('Unknown format option provided.'); 998 } 999 format = opts.format; 1000 } 1001 var formatter = formats.formatters[format]; 1002 1003 var filter = defaults.filter; 1004 if (typeof opts.filter === 'function' || isArray(opts.filter)) { 1005 filter = opts.filter; 1006 } 1007 1008 return { 1009 addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, 1010 allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, 1011 charset: charset, 1012 charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, 1013 delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, 1014 encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, 1015 encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, 1016 encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, 1017 filter: filter, 1018 formatter: formatter, 1019 serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, 1020 skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, 1021 sort: typeof opts.sort === 'function' ? opts.sort : null, 1022 strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling 1023 }; 1024 }; 1025 1026 module.exports = function (object, opts) { 1027 var obj = object; 1028 var options = normalizeStringifyOptions(opts); 1029 1030 var objKeys; 1031 var filter; 1032 1033 if (typeof options.filter === 'function') { 1034 filter = options.filter; 1035 obj = filter('', obj); 1036 } else if (isArray(options.filter)) { 1037 filter = options.filter; 1038 objKeys = filter; 1039 } 1040 1041 var keys = []; 1042 1043 if (typeof obj !== 'object' || obj === null) { 1044 return ''; 1045 } 1046 1047 var arrayFormat; 1048 if (opts && opts.arrayFormat in arrayPrefixGenerators) { 1049 arrayFormat = opts.arrayFormat; 1050 } else if (opts && 'indices' in opts) { 1051 arrayFormat = opts.indices ? 'indices' : 'repeat'; 1052 } else { 1053 arrayFormat = 'indices'; 1054 } 1055 1056 var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; 1057 1058 if (!objKeys) { 1059 objKeys = Object.keys(obj); 1060 } 1061 1062 if (options.sort) { 1063 objKeys.sort(options.sort); 1064 } 1065 1066 for (var i = 0; i < objKeys.length; ++i) { 1067 var key = objKeys[i]; 1068 1069 if (options.skipNulls && obj[key] === null) { 1070 continue; 1071 } 1072 pushToArray(keys, stringify( 1073 obj[key], 1074 key, 1075 generateArrayPrefix, 1076 options.strictNullHandling, 1077 options.skipNulls, 1078 options.encode ? options.encoder : null, 1079 options.filter, 1080 options.sort, 1081 options.allowDots, 1082 options.serializeDate, 1083 options.formatter, 1084 options.encodeValuesOnly, 1085 options.charset 1086 )); 1087 } 1088 1089 var joined = keys.join(options.delimiter); 1090 var prefix = options.addQueryPrefix === true ? '?' : ''; 1091 1092 if (options.charsetSentinel) { 1093 if (options.charset === 'iso-8859-1') { 1094 // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark 1095 prefix += 'utf8=%26%2310003%3B&'; 1096 } else { 1097 // encodeURIComponent('✓') 1098 prefix += 'utf8=%E2%9C%93&'; 1099 } 1100 } 1101 1102 return joined.length > 0 ? prefix + joined : ''; 1103 }; 1104 1105 1106 /***/ }), 1107 1108 /***/ 340: 1109 /***/ (function(module, exports, __webpack_require__) { 1110 1111 "use strict"; 1112 1113 1114 var utils = __webpack_require__(214); 1115 1116 var has = Object.prototype.hasOwnProperty; 1117 1118 var defaults = { 1119 allowDots: false, 1120 allowPrototypes: false, 1121 arrayLimit: 20, 1122 charset: 'utf-8', 1123 charsetSentinel: false, 1124 comma: false, 1125 decoder: utils.decode, 1126 delimiter: '&', 1127 depth: 5, 1128 ignoreQueryPrefix: false, 1129 interpretNumericEntities: false, 1130 parameterLimit: 1000, 1131 parseArrays: true, 1132 plainObjects: false, 1133 strictNullHandling: false 1134 }; 1135 1136 var interpretNumericEntities = function (str) { 1137 return str.replace(/&#(\d+);/g, function ($0, numberStr) { 1138 return String.fromCharCode(parseInt(numberStr, 10)); 1139 }); 1140 }; 1141 1142 // This is what browsers will submit when the ✓ character occurs in an 1143 // application/x-www-form-urlencoded body and the encoding of the page containing 1144 // the form is iso-8859-1, or when the submitted form has an accept-charset 1145 // attribute of iso-8859-1. Presumably also with other charsets that do not contain 1146 // the ✓ character, such as us-ascii. 1147 var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') 1148 1149 // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. 1150 var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') 1151 1152 var parseValues = function parseQueryStringValues(str, options) { 1153 var obj = {}; 1154 var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; 1155 var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; 1156 var parts = cleanStr.split(options.delimiter, limit); 1157 var skipIndex = -1; // Keep track of where the utf8 sentinel was found 1158 var i; 1159 1160 var charset = options.charset; 1161 if (options.charsetSentinel) { 1162 for (i = 0; i < parts.length; ++i) { 1163 if (parts[i].indexOf('utf8=') === 0) { 1164 if (parts[i] === charsetSentinel) { 1165 charset = 'utf-8'; 1166 } else if (parts[i] === isoSentinel) { 1167 charset = 'iso-8859-1'; 1168 } 1169 skipIndex = i; 1170 i = parts.length; // The eslint settings do not allow break; 1171 } 1172 } 1173 } 1174 1175 for (i = 0; i < parts.length; ++i) { 1176 if (i === skipIndex) { 1177 continue; 1178 } 1179 var part = parts[i]; 1180 1181 var bracketEqualsPos = part.indexOf(']='); 1182 var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; 1183 1184 var key, val; 1185 if (pos === -1) { 1186 key = options.decoder(part, defaults.decoder, charset); 1187 val = options.strictNullHandling ? null : ''; 1188 } else { 1189 key = options.decoder(part.slice(0, pos), defaults.decoder, charset); 1190 val = options.decoder(part.slice(pos + 1), defaults.decoder, charset); 1191 } 1192 1193 if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { 1194 val = interpretNumericEntities(val); 1195 } 1196 1197 if (val && options.comma && val.indexOf(',') > -1) { 1198 val = val.split(','); 1199 } 1200 1201 if (has.call(obj, key)) { 1202 obj[key] = utils.combine(obj[key], val); 1203 } else { 1204 obj[key] = val; 1205 } 1206 } 1207 1208 return obj; 1209 }; 1210 1211 var parseObject = function (chain, val, options) { 1212 var leaf = val; 1213 1214 for (var i = chain.length - 1; i >= 0; --i) { 1215 var obj; 1216 var root = chain[i]; 1217 1218 if (root === '[]' && options.parseArrays) { 1219 obj = [].concat(leaf); 1220 } else { 1221 obj = options.plainObjects ? Object.create(null) : {}; 1222 var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; 1223 var index = parseInt(cleanRoot, 10); 1224 if (!options.parseArrays && cleanRoot === '') { 1225 obj = { 0: leaf }; 1226 } else if ( 1227 !isNaN(index) 1228 && root !== cleanRoot 1229 && String(index) === cleanRoot 1230 && index >= 0 1231 && (options.parseArrays && index <= options.arrayLimit) 1232 ) { 1233 obj = []; 1234 obj[index] = leaf; 1235 } else { 1236 obj[cleanRoot] = leaf; 1237 } 1238 } 1239 1240 leaf = obj; 1241 } 1242 1243 return leaf; 1244 }; 1245 1246 var parseKeys = function parseQueryStringKeys(givenKey, val, options) { 1247 if (!givenKey) { 1248 return; 1249 } 1250 1251 // Transform dot notation to bracket notation 1252 var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; 1253 1254 // The regex chunks 1255 1256 var brackets = /(\[[^[\]]*])/; 1257 var child = /(\[[^[\]]*])/g; 1258 1259 // Get the parent 1260 1261 var segment = brackets.exec(key); 1262 var parent = segment ? key.slice(0, segment.index) : key; 1263 1264 // Stash the parent if it exists 1265 1266 var keys = []; 1267 if (parent) { 1268 // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties 1269 if (!options.plainObjects && has.call(Object.prototype, parent)) { 1270 if (!options.allowPrototypes) { 1271 return; 1272 } 1273 } 1274 1275 keys.push(parent); 1276 } 1277 1278 // Loop through children appending to the array until we hit depth 1279 1280 var i = 0; 1281 while ((segment = child.exec(key)) !== null && i < options.depth) { 1282 i += 1; 1283 if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { 1284 if (!options.allowPrototypes) { 1285 return; 1286 } 1287 } 1288 keys.push(segment[1]); 1289 } 1290 1291 // If there's a remainder, just add whatever is left 1292 1293 if (segment) { 1294 keys.push('[' + key.slice(segment.index) + ']'); 1295 } 1296 1297 return parseObject(keys, val, options); 1298 }; 1299 1300 var normalizeParseOptions = function normalizeParseOptions(opts) { 1301 if (!opts) { 1302 return defaults; 1303 } 1304 1305 if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { 1306 throw new TypeError('Decoder has to be a function.'); 1307 } 1308 1309 if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { 1310 throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); 1311 } 1312 var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; 1313 1314 return { 1315 allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, 1316 allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, 1317 arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, 1318 charset: charset, 1319 charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, 1320 comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, 1321 decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, 1322 delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, 1323 depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth, 1324 ignoreQueryPrefix: opts.ignoreQueryPrefix === true, 1325 interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, 1326 parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, 1327 parseArrays: opts.parseArrays !== false, 1328 plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, 1329 strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling 1330 }; 1331 }; 1332 1333 module.exports = function (str, opts) { 1334 var options = normalizeParseOptions(opts); 1335 1336 if (str === '' || str === null || typeof str === 'undefined') { 1337 return options.plainObjects ? Object.create(null) : {}; 1338 } 1339 1340 var tempObj = typeof str === 'string' ? parseValues(str, options) : str; 1341 var obj = options.plainObjects ? Object.create(null) : {}; 1342 1343 // Iterate over the keys and setup the new object 1344 1345 var keys = Object.keys(tempObj); 1346 for (var i = 0; i < keys.length; ++i) { 1347 var key = keys[i]; 1348 var newObj = parseKeys(key, tempObj[key], options); 1349 obj = utils.merge(obj, newObj, options); 1350 } 1351 1352 return utils.compact(obj); 1353 }; 1354 1355 1356 /***/ }), 1357 1358 /***/ 84: 1359 /***/ (function(module, exports, __webpack_require__) { 1360 1361 "use strict"; 1362 1363 1364 var stringify = __webpack_require__(339); 1365 var parse = __webpack_require__(340); 1366 var formats = __webpack_require__(215); 1367 1368 module.exports = { 1369 formats: formats, 1370 parse: parse, 1371 stringify: stringify 1372 }; 1373 1374 1375 /***/ }) 1376 1377 /******/ });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Nov 23 20:47:33 2019 | Cross-referenced by PHPXref 0.7 |