347 }; |
375 }; |
348 |
376 |
349 |
377 |
350 /***/ }), |
378 /***/ }), |
351 |
379 |
352 /***/ 354: |
380 /***/ 433: |
353 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
381 /***/ (function(module, exports, __webpack_require__) { |
354 |
382 |
355 "use strict"; |
383 "use strict"; |
356 __webpack_require__.r(__webpack_exports__); |
384 |
357 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isURL", function() { return isURL; }); |
385 |
358 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getProtocol", function() { return getProtocol; }); |
386 var utils = __webpack_require__(258); |
359 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return isValidProtocol; }); |
387 var formats = __webpack_require__(259); |
360 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAuthority", function() { return getAuthority; }); |
388 var has = Object.prototype.hasOwnProperty; |
361 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return isValidAuthority; }); |
|
362 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getPath", function() { return getPath; }); |
|
363 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidPath", function() { return isValidPath; }); |
|
364 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryString", function() { return getQueryString; }); |
|
365 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return isValidQueryString; }); |
|
366 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFragment", function() { return getFragment; }); |
|
367 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return isValidFragment; }); |
|
368 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return addQueryArgs; }); |
|
369 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return getQueryArg; }); |
|
370 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return hasQueryArg; }); |
|
371 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return removeQueryArgs; }); |
|
372 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return prependHTTP; }); |
|
373 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return safeDecodeURI; }); |
|
374 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return filterURLForDisplay; }); |
|
375 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeDecodeURIComponent", function() { return safeDecodeURIComponent; }); |
|
376 /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(86); |
|
377 /* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_0__); |
|
378 /** |
|
379 * External dependencies |
|
380 */ |
|
381 |
|
382 var URL_REGEXP = /^(?:https?:)?\/\/\S+$/i; |
|
383 var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; |
|
384 var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; |
|
385 /** |
|
386 * Determines whether the given string looks like a URL. |
|
387 * |
|
388 * @param {string} url The string to scrutinise. |
|
389 * |
|
390 * @example |
|
391 * ```js |
|
392 * const isURL = isURL( 'https://wordpress.org' ); // true |
|
393 * ``` |
|
394 * |
|
395 * @return {boolean} Whether or not it looks like a URL. |
|
396 */ |
|
397 |
|
398 function isURL(url) { |
|
399 return URL_REGEXP.test(url); |
|
400 } |
|
401 /** |
|
402 * Returns the protocol part of the URL. |
|
403 * |
|
404 * @param {string} url The full URL. |
|
405 * |
|
406 * @example |
|
407 * ```js |
|
408 * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' |
|
409 * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' |
|
410 * ``` |
|
411 * |
|
412 * @return {?string} The protocol part of the URL. |
|
413 */ |
|
414 |
|
415 function getProtocol(url) { |
|
416 var matches = /^([^\s:]+:)/.exec(url); |
|
417 |
|
418 if (matches) { |
|
419 return matches[1]; |
|
420 } |
|
421 } |
|
422 /** |
|
423 * Tests if a url protocol is valid. |
|
424 * |
|
425 * @param {string} protocol The url protocol. |
|
426 * |
|
427 * @example |
|
428 * ```js |
|
429 * const isValid = isValidProtocol( 'https:' ); // true |
|
430 * const isNotValid = isValidProtocol( 'https :' ); // false |
|
431 * ``` |
|
432 * |
|
433 * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). |
|
434 */ |
|
435 |
|
436 function isValidProtocol(protocol) { |
|
437 if (!protocol) { |
|
438 return false; |
|
439 } |
|
440 |
|
441 return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); |
|
442 } |
|
443 /** |
|
444 * Returns the authority part of the URL. |
|
445 * |
|
446 * @param {string} url The full URL. |
|
447 * |
|
448 * @example |
|
449 * ```js |
|
450 * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' |
|
451 * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' |
|
452 * ``` |
|
453 * |
|
454 * @return {?string} The authority part of the URL. |
|
455 */ |
|
456 |
|
457 function getAuthority(url) { |
|
458 var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); |
|
459 |
|
460 if (matches) { |
|
461 return matches[1]; |
|
462 } |
|
463 } |
|
464 /** |
|
465 * Checks for invalid characters within the provided authority. |
|
466 * |
|
467 * @param {string} authority A string containing the URL authority. |
|
468 * |
|
469 * @example |
|
470 * ```js |
|
471 * const isValid = isValidAuthority( 'wordpress.org' ); // true |
|
472 * const isNotValid = isValidAuthority( 'wordpress#org' ); // false |
|
473 * ``` |
|
474 * |
|
475 * @return {boolean} True if the argument contains a valid authority. |
|
476 */ |
|
477 |
|
478 function isValidAuthority(authority) { |
|
479 if (!authority) { |
|
480 return false; |
|
481 } |
|
482 |
|
483 return /^[^\s#?]+$/.test(authority); |
|
484 } |
|
485 /** |
|
486 * Returns the path part of the URL. |
|
487 * |
|
488 * @param {string} url The full URL. |
|
489 * |
|
490 * @example |
|
491 * ```js |
|
492 * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' |
|
493 * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' |
|
494 * ``` |
|
495 * |
|
496 * @return {?string} The path part of the URL. |
|
497 */ |
|
498 |
|
499 function getPath(url) { |
|
500 var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); |
|
501 |
|
502 if (matches) { |
|
503 return matches[1]; |
|
504 } |
|
505 } |
|
506 /** |
|
507 * Checks for invalid characters within the provided path. |
|
508 * |
|
509 * @param {string} path The URL path. |
|
510 * |
|
511 * @example |
|
512 * ```js |
|
513 * const isValid = isValidPath( 'test/path/' ); // true |
|
514 * const isNotValid = isValidPath( '/invalid?test/path/' ); // false |
|
515 * ``` |
|
516 * |
|
517 * @return {boolean} True if the argument contains a valid path |
|
518 */ |
|
519 |
|
520 function isValidPath(path) { |
|
521 if (!path) { |
|
522 return false; |
|
523 } |
|
524 |
|
525 return /^[^\s#?]+$/.test(path); |
|
526 } |
|
527 /** |
|
528 * Returns the query string part of the URL. |
|
529 * |
|
530 * @param {string} url The full URL. |
|
531 * |
|
532 * @example |
|
533 * ```js |
|
534 * const queryString1 = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' |
|
535 * const queryString2 = getQueryString( 'https://wordpress.org#fragment?query=false&search=hello' ); // 'query=false&search=hello' |
|
536 * ``` |
|
537 * |
|
538 * @return {?string} The query string part of the URL. |
|
539 */ |
|
540 |
|
541 function getQueryString(url) { |
|
542 var matches = /^\S+?\?([^\s#]+)/.exec(url); |
|
543 |
|
544 if (matches) { |
|
545 return matches[1]; |
|
546 } |
|
547 } |
|
548 /** |
|
549 * Checks for invalid characters within the provided query string. |
|
550 * |
|
551 * @param {string} queryString The query string. |
|
552 * |
|
553 * @example |
|
554 * ```js |
|
555 * const isValid = isValidQueryString( 'query=true&another=false' ); // true |
|
556 * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false |
|
557 * ``` |
|
558 * |
|
559 * @return {boolean} True if the argument contains a valid query string. |
|
560 */ |
|
561 |
|
562 function isValidQueryString(queryString) { |
|
563 if (!queryString) { |
|
564 return false; |
|
565 } |
|
566 |
|
567 return /^[^\s#?\/]+$/.test(queryString); |
|
568 } |
|
569 /** |
|
570 * Returns the fragment part of the URL. |
|
571 * |
|
572 * @param {string} url The full URL |
|
573 * |
|
574 * @example |
|
575 * ```js |
|
576 * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' |
|
577 * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' |
|
578 * ``` |
|
579 * |
|
580 * @return {?string} The fragment part of the URL. |
|
581 */ |
|
582 |
|
583 function getFragment(url) { |
|
584 var matches = /^\S+?(#[^\s\?]*)/.exec(url); |
|
585 |
|
586 if (matches) { |
|
587 return matches[1]; |
|
588 } |
|
589 } |
|
590 /** |
|
591 * Checks for invalid characters within the provided fragment. |
|
592 * |
|
593 * @param {string} fragment The url fragment. |
|
594 * |
|
595 * @example |
|
596 * ```js |
|
597 * const isValid = isValidFragment( '#valid-fragment' ); // true |
|
598 * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false |
|
599 * ``` |
|
600 * |
|
601 * @return {boolean} True if the argument contains a valid fragment. |
|
602 */ |
|
603 |
|
604 function isValidFragment(fragment) { |
|
605 if (!fragment) { |
|
606 return false; |
|
607 } |
|
608 |
|
609 return /^#[^\s#?\/]*$/.test(fragment); |
|
610 } |
|
611 /** |
|
612 * Appends arguments as querystring to the provided URL. If the URL already |
|
613 * includes query arguments, the arguments are merged with (and take precedent |
|
614 * over) the existing set. |
|
615 * |
|
616 * @param {?string} url URL to which arguments should be appended. If omitted, |
|
617 * only the resulting querystring is returned. |
|
618 * @param {Object} args Query arguments to apply to URL. |
|
619 * |
|
620 * @example |
|
621 * ```js |
|
622 * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test |
|
623 * ``` |
|
624 * |
|
625 * @return {string} URL with arguments applied. |
|
626 */ |
|
627 |
|
628 function addQueryArgs() { |
|
629 var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
630 var args = arguments.length > 1 ? arguments[1] : undefined; |
|
631 |
|
632 // If no arguments are to be appended, return original URL. |
|
633 if (!args || !Object.keys(args).length) { |
|
634 return url; |
|
635 } |
|
636 |
|
637 var baseUrl = url; // Determine whether URL already had query arguments. |
|
638 |
|
639 var queryStringIndex = url.indexOf('?'); |
|
640 |
|
641 if (queryStringIndex !== -1) { |
|
642 // Merge into existing query arguments. |
|
643 args = Object.assign(Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)), args); // Change working base URL to omit previous query arguments. |
|
644 |
|
645 baseUrl = baseUrl.substr(0, queryStringIndex); |
|
646 } |
|
647 |
|
648 return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(args); |
|
649 } |
|
650 /** |
|
651 * Returns a single query argument of the url |
|
652 * |
|
653 * @param {string} url URL |
|
654 * @param {string} arg Query arg name |
|
655 * |
|
656 * @example |
|
657 * ```js |
|
658 * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar |
|
659 * ``` |
|
660 * |
|
661 * @return {Array|string} Query arg value. |
|
662 */ |
|
663 |
|
664 function getQueryArg(url, arg) { |
|
665 var queryStringIndex = url.indexOf('?'); |
|
666 var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
667 return query[arg]; |
|
668 } |
|
669 /** |
|
670 * Determines whether the URL contains a given query arg. |
|
671 * |
|
672 * @param {string} url URL |
|
673 * @param {string} arg Query arg name |
|
674 * |
|
675 * @example |
|
676 * ```js |
|
677 * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true |
|
678 * ``` |
|
679 * |
|
680 * @return {boolean} Whether or not the URL contains the query arg. |
|
681 */ |
|
682 |
|
683 function hasQueryArg(url, arg) { |
|
684 return getQueryArg(url, arg) !== undefined; |
|
685 } |
|
686 /** |
|
687 * Removes arguments from the query string of the url |
|
688 * |
|
689 * @param {string} url URL |
|
690 * @param {...string} args Query Args |
|
691 * |
|
692 * @example |
|
693 * ```js |
|
694 * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar |
|
695 * ``` |
|
696 * |
|
697 * @return {string} Updated URL |
|
698 */ |
|
699 |
|
700 function removeQueryArgs(url) { |
|
701 var queryStringIndex = url.indexOf('?'); |
|
702 var query = queryStringIndex !== -1 ? Object(qs__WEBPACK_IMPORTED_MODULE_0__["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
703 var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; |
|
704 |
|
705 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
706 args[_key - 1] = arguments[_key]; |
|
707 } |
|
708 |
|
709 args.forEach(function (arg) { |
|
710 return delete query[arg]; |
|
711 }); |
|
712 return baseUrl + '?' + Object(qs__WEBPACK_IMPORTED_MODULE_0__["stringify"])(query); |
|
713 } |
|
714 /** |
|
715 * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. |
|
716 * |
|
717 * @param {string} url The URL to test |
|
718 * |
|
719 * @example |
|
720 * ```js |
|
721 * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org |
|
722 * ``` |
|
723 * |
|
724 * @return {string} The updated URL |
|
725 */ |
|
726 |
|
727 function prependHTTP(url) { |
|
728 if (!USABLE_HREF_REGEXP.test(url) && !EMAIL_REGEXP.test(url)) { |
|
729 return 'http://' + url; |
|
730 } |
|
731 |
|
732 return url; |
|
733 } |
|
734 /** |
|
735 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if |
|
736 * `decodeURI` throws an error. |
|
737 * |
|
738 * @param {string} uri URI to decode. |
|
739 * |
|
740 * @example |
|
741 * ```js |
|
742 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' |
|
743 * ``` |
|
744 * |
|
745 * @return {string} Decoded URI if possible. |
|
746 */ |
|
747 |
|
748 function safeDecodeURI(uri) { |
|
749 try { |
|
750 return decodeURI(uri); |
|
751 } catch (uriError) { |
|
752 return uri; |
|
753 } |
|
754 } |
|
755 /** |
|
756 * Returns a URL for display. |
|
757 * |
|
758 * @param {string} url Original URL. |
|
759 * |
|
760 * @example |
|
761 * ```js |
|
762 * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg |
|
763 * ``` |
|
764 * |
|
765 * @return {string} Displayed URL. |
|
766 */ |
|
767 |
|
768 function filterURLForDisplay(url) { |
|
769 // Remove protocol and www prefixes. |
|
770 var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. |
|
771 |
|
772 if (filteredURL.match(/^[^\/]+\/$/)) { |
|
773 return filteredURL.replace('/', ''); |
|
774 } |
|
775 |
|
776 return filteredURL; |
|
777 } |
|
778 /** |
|
779 * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if |
|
780 * `decodeURIComponent` throws an error. |
|
781 * |
|
782 * @param {string} uriComponent URI component to decode. |
|
783 * |
|
784 * @return {string} Decoded URI component if possible. |
|
785 */ |
|
786 |
|
787 function safeDecodeURIComponent(uriComponent) { |
|
788 try { |
|
789 return decodeURIComponent(uriComponent); |
|
790 } catch (uriComponentError) { |
|
791 return uriComponent; |
|
792 } |
|
793 } |
|
794 |
|
795 |
|
796 /***/ }), |
|
797 |
|
798 /***/ 355: |
|
799 /***/ (function(module, exports, __webpack_require__) { |
|
800 |
|
801 "use strict"; |
|
802 |
|
803 |
|
804 var utils = __webpack_require__(201); |
|
805 var formats = __webpack_require__(202); |
|
806 |
389 |
807 var arrayPrefixGenerators = { |
390 var arrayPrefixGenerators = { |
808 brackets: function brackets(prefix) { // eslint-disable-line func-name-matching |
391 brackets: function brackets(prefix) { // eslint-disable-line func-name-matching |
809 return prefix + '[]'; |
392 return prefix + '[]'; |
810 }, |
393 }, |
|
394 comma: 'comma', |
811 indices: function indices(prefix, key) { // eslint-disable-line func-name-matching |
395 indices: function indices(prefix, key) { // eslint-disable-line func-name-matching |
812 return prefix + '[' + key + ']'; |
396 return prefix + '[' + key + ']'; |
813 }, |
397 }, |
814 repeat: function repeat(prefix) { // eslint-disable-line func-name-matching |
398 repeat: function repeat(prefix) { // eslint-disable-line func-name-matching |
815 return prefix; |
399 return prefix; |
937 } |
524 } |
938 |
525 |
939 return values; |
526 return values; |
940 }; |
527 }; |
941 |
528 |
|
529 var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { |
|
530 if (!opts) { |
|
531 return defaults; |
|
532 } |
|
533 |
|
534 if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { |
|
535 throw new TypeError('Encoder has to be a function.'); |
|
536 } |
|
537 |
|
538 var charset = opts.charset || defaults.charset; |
|
539 if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { |
|
540 throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); |
|
541 } |
|
542 |
|
543 var format = formats['default']; |
|
544 if (typeof opts.format !== 'undefined') { |
|
545 if (!has.call(formats.formatters, opts.format)) { |
|
546 throw new TypeError('Unknown format option provided.'); |
|
547 } |
|
548 format = opts.format; |
|
549 } |
|
550 var formatter = formats.formatters[format]; |
|
551 |
|
552 var filter = defaults.filter; |
|
553 if (typeof opts.filter === 'function' || isArray(opts.filter)) { |
|
554 filter = opts.filter; |
|
555 } |
|
556 |
|
557 return { |
|
558 addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, |
|
559 allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, |
|
560 charset: charset, |
|
561 charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, |
|
562 delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, |
|
563 encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, |
|
564 encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, |
|
565 encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, |
|
566 filter: filter, |
|
567 formatter: formatter, |
|
568 serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, |
|
569 skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, |
|
570 sort: typeof opts.sort === 'function' ? opts.sort : null, |
|
571 strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling |
|
572 }; |
|
573 }; |
|
574 |
942 module.exports = function (object, opts) { |
575 module.exports = function (object, opts) { |
943 var obj = object; |
576 var obj = object; |
944 var options = opts ? utils.assign({}, opts) : {}; |
577 var options = normalizeStringifyOptions(opts); |
945 |
578 |
946 if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { |
|
947 throw new TypeError('Encoder has to be a function.'); |
|
948 } |
|
949 |
|
950 var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; |
|
951 var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; |
|
952 var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; |
|
953 var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; |
|
954 var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder; |
|
955 var sort = typeof options.sort === 'function' ? options.sort : null; |
|
956 var allowDots = typeof options.allowDots === 'undefined' ? defaults.allowDots : !!options.allowDots; |
|
957 var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate; |
|
958 var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly; |
|
959 var charset = options.charset || defaults.charset; |
|
960 if (typeof options.charset !== 'undefined' && options.charset !== 'utf-8' && options.charset !== 'iso-8859-1') { |
|
961 throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); |
|
962 } |
|
963 |
|
964 if (typeof options.format === 'undefined') { |
|
965 options.format = formats['default']; |
|
966 } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) { |
|
967 throw new TypeError('Unknown format option provided.'); |
|
968 } |
|
969 var formatter = formats.formatters[options.format]; |
|
970 var objKeys; |
579 var objKeys; |
971 var filter; |
580 var filter; |
972 |
581 |
973 if (typeof options.filter === 'function') { |
582 if (typeof options.filter === 'function') { |
974 filter = options.filter; |
583 filter = options.filter; |
975 obj = filter('', obj); |
584 obj = filter('', obj); |
976 } else if (Array.isArray(options.filter)) { |
585 } else if (isArray(options.filter)) { |
977 filter = options.filter; |
586 filter = options.filter; |
978 objKeys = filter; |
587 objKeys = filter; |
979 } |
588 } |
980 |
589 |
981 var keys = []; |
590 var keys = []; |
1229 } |
844 } |
1230 |
845 |
1231 return parseObject(keys, val, options); |
846 return parseObject(keys, val, options); |
1232 }; |
847 }; |
1233 |
848 |
|
849 var normalizeParseOptions = function normalizeParseOptions(opts) { |
|
850 if (!opts) { |
|
851 return defaults; |
|
852 } |
|
853 |
|
854 if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { |
|
855 throw new TypeError('Decoder has to be a function.'); |
|
856 } |
|
857 |
|
858 if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { |
|
859 throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); |
|
860 } |
|
861 var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; |
|
862 |
|
863 return { |
|
864 allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, |
|
865 allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, |
|
866 arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, |
|
867 charset: charset, |
|
868 charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, |
|
869 comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, |
|
870 decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, |
|
871 delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, |
|
872 depth: typeof opts.depth === 'number' ? opts.depth : defaults.depth, |
|
873 ignoreQueryPrefix: opts.ignoreQueryPrefix === true, |
|
874 interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, |
|
875 parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, |
|
876 parseArrays: opts.parseArrays !== false, |
|
877 plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, |
|
878 strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling |
|
879 }; |
|
880 }; |
|
881 |
1234 module.exports = function (str, opts) { |
882 module.exports = function (str, opts) { |
1235 var options = opts ? utils.assign({}, opts) : {}; |
883 var options = normalizeParseOptions(opts); |
1236 |
|
1237 if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') { |
|
1238 throw new TypeError('Decoder has to be a function.'); |
|
1239 } |
|
1240 |
|
1241 options.ignoreQueryPrefix = options.ignoreQueryPrefix === true; |
|
1242 options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter; |
|
1243 options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth; |
|
1244 options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit; |
|
1245 options.parseArrays = options.parseArrays !== false; |
|
1246 options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder; |
|
1247 options.allowDots = typeof options.allowDots === 'undefined' ? defaults.allowDots : !!options.allowDots; |
|
1248 options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects; |
|
1249 options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes; |
|
1250 options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit; |
|
1251 options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; |
|
1252 |
|
1253 if (typeof options.charset !== 'undefined' && options.charset !== 'utf-8' && options.charset !== 'iso-8859-1') { |
|
1254 throw new Error('The charset option must be either utf-8, iso-8859-1, or undefined'); |
|
1255 } |
|
1256 if (typeof options.charset === 'undefined') { |
|
1257 options.charset = defaults.charset; |
|
1258 } |
|
1259 |
884 |
1260 if (str === '' || str === null || typeof str === 'undefined') { |
885 if (str === '' || str === null || typeof str === 'undefined') { |
1261 return options.plainObjects ? Object.create(null) : {}; |
886 return options.plainObjects ? Object.create(null) : {}; |
1262 } |
887 } |
1263 |
888 |
1277 }; |
902 }; |
1278 |
903 |
1279 |
904 |
1280 /***/ }), |
905 /***/ }), |
1281 |
906 |
1282 /***/ 86: |
907 /***/ 444: |
1283 /***/ (function(module, exports, __webpack_require__) { |
908 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
1284 |
909 |
1285 "use strict"; |
910 "use strict"; |
1286 |
911 // ESM COMPAT FLAG |
1287 |
912 __webpack_require__.r(__webpack_exports__); |
1288 var stringify = __webpack_require__(355); |
913 |
1289 var parse = __webpack_require__(356); |
914 // EXPORTS |
1290 var formats = __webpack_require__(202); |
915 __webpack_require__.d(__webpack_exports__, "isURL", function() { return /* reexport */ isURL; }); |
1291 |
916 __webpack_require__.d(__webpack_exports__, "isEmail", function() { return /* reexport */ isEmail; }); |
1292 module.exports = { |
917 __webpack_require__.d(__webpack_exports__, "getProtocol", function() { return /* reexport */ getProtocol; }); |
1293 formats: formats, |
918 __webpack_require__.d(__webpack_exports__, "isValidProtocol", function() { return /* reexport */ isValidProtocol; }); |
1294 parse: parse, |
919 __webpack_require__.d(__webpack_exports__, "getAuthority", function() { return /* reexport */ getAuthority; }); |
1295 stringify: stringify |
920 __webpack_require__.d(__webpack_exports__, "isValidAuthority", function() { return /* reexport */ isValidAuthority; }); |
1296 }; |
921 __webpack_require__.d(__webpack_exports__, "getPath", function() { return /* reexport */ getPath; }); |
|
922 __webpack_require__.d(__webpack_exports__, "isValidPath", function() { return /* reexport */ isValidPath; }); |
|
923 __webpack_require__.d(__webpack_exports__, "getQueryString", function() { return /* reexport */ getQueryString; }); |
|
924 __webpack_require__.d(__webpack_exports__, "isValidQueryString", function() { return /* reexport */ isValidQueryString; }); |
|
925 __webpack_require__.d(__webpack_exports__, "getPathAndQueryString", function() { return /* reexport */ getPathAndQueryString; }); |
|
926 __webpack_require__.d(__webpack_exports__, "getFragment", function() { return /* reexport */ getFragment; }); |
|
927 __webpack_require__.d(__webpack_exports__, "isValidFragment", function() { return /* reexport */ isValidFragment; }); |
|
928 __webpack_require__.d(__webpack_exports__, "addQueryArgs", function() { return /* reexport */ addQueryArgs; }); |
|
929 __webpack_require__.d(__webpack_exports__, "getQueryArg", function() { return /* reexport */ getQueryArg; }); |
|
930 __webpack_require__.d(__webpack_exports__, "hasQueryArg", function() { return /* reexport */ hasQueryArg; }); |
|
931 __webpack_require__.d(__webpack_exports__, "removeQueryArgs", function() { return /* reexport */ removeQueryArgs; }); |
|
932 __webpack_require__.d(__webpack_exports__, "prependHTTP", function() { return /* reexport */ prependHTTP; }); |
|
933 __webpack_require__.d(__webpack_exports__, "safeDecodeURI", function() { return /* reexport */ safeDecodeURI; }); |
|
934 __webpack_require__.d(__webpack_exports__, "safeDecodeURIComponent", function() { return /* reexport */ safeDecodeURIComponent; }); |
|
935 __webpack_require__.d(__webpack_exports__, "filterURLForDisplay", function() { return /* reexport */ filterURLForDisplay; }); |
|
936 __webpack_require__.d(__webpack_exports__, "cleanForSlug", function() { return /* reexport */ cleanForSlug; }); |
|
937 |
|
938 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-url.js |
|
939 /** |
|
940 * Determines whether the given string looks like a URL. |
|
941 * |
|
942 * @param {string} url The string to scrutinise. |
|
943 * |
|
944 * @example |
|
945 * ```js |
|
946 * const isURL = isURL( 'https://wordpress.org' ); // true |
|
947 * ``` |
|
948 * |
|
949 * @see https://url.spec.whatwg.org/ |
|
950 * @see https://url.spec.whatwg.org/#valid-url-string |
|
951 * |
|
952 * @return {boolean} Whether or not it looks like a URL. |
|
953 */ |
|
954 function isURL(url) { |
|
955 // A URL can be considered value if the `URL` constructor is able to parse |
|
956 // it. The constructor throws an error for an invalid URL. |
|
957 try { |
|
958 new URL(url); |
|
959 return true; |
|
960 } catch (_unused) { |
|
961 return false; |
|
962 } |
|
963 } |
|
964 |
|
965 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-email.js |
|
966 var EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i; |
|
967 /** |
|
968 * Determines whether the given string looks like an email. |
|
969 * |
|
970 * @param {string} email The string to scrutinise. |
|
971 * |
|
972 * @example |
|
973 * ```js |
|
974 * const isEmail = isEmail( 'hello@wordpress.org' ); // true |
|
975 * ``` |
|
976 * |
|
977 * @return {boolean} Whether or not it looks like an email. |
|
978 */ |
|
979 |
|
980 function isEmail(email) { |
|
981 return EMAIL_REGEXP.test(email); |
|
982 } |
|
983 |
|
984 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-protocol.js |
|
985 /** |
|
986 * Returns the protocol part of the URL. |
|
987 * |
|
988 * @param {string} url The full URL. |
|
989 * |
|
990 * @example |
|
991 * ```js |
|
992 * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:' |
|
993 * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:' |
|
994 * ``` |
|
995 * |
|
996 * @return {string|void} The protocol part of the URL. |
|
997 */ |
|
998 function getProtocol(url) { |
|
999 var matches = /^([^\s:]+:)/.exec(url); |
|
1000 |
|
1001 if (matches) { |
|
1002 return matches[1]; |
|
1003 } |
|
1004 } |
|
1005 |
|
1006 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-protocol.js |
|
1007 /** |
|
1008 * Tests if a url protocol is valid. |
|
1009 * |
|
1010 * @param {string} protocol The url protocol. |
|
1011 * |
|
1012 * @example |
|
1013 * ```js |
|
1014 * const isValid = isValidProtocol( 'https:' ); // true |
|
1015 * const isNotValid = isValidProtocol( 'https :' ); // false |
|
1016 * ``` |
|
1017 * |
|
1018 * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:). |
|
1019 */ |
|
1020 function isValidProtocol(protocol) { |
|
1021 if (!protocol) { |
|
1022 return false; |
|
1023 } |
|
1024 |
|
1025 return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol); |
|
1026 } |
|
1027 |
|
1028 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-authority.js |
|
1029 /** |
|
1030 * Returns the authority part of the URL. |
|
1031 * |
|
1032 * @param {string} url The full URL. |
|
1033 * |
|
1034 * @example |
|
1035 * ```js |
|
1036 * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org' |
|
1037 * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080' |
|
1038 * ``` |
|
1039 * |
|
1040 * @return {string|void} The authority part of the URL. |
|
1041 */ |
|
1042 function getAuthority(url) { |
|
1043 var matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url); |
|
1044 |
|
1045 if (matches) { |
|
1046 return matches[1]; |
|
1047 } |
|
1048 } |
|
1049 |
|
1050 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-authority.js |
|
1051 /** |
|
1052 * Checks for invalid characters within the provided authority. |
|
1053 * |
|
1054 * @param {string} authority A string containing the URL authority. |
|
1055 * |
|
1056 * @example |
|
1057 * ```js |
|
1058 * const isValid = isValidAuthority( 'wordpress.org' ); // true |
|
1059 * const isNotValid = isValidAuthority( 'wordpress#org' ); // false |
|
1060 * ``` |
|
1061 * |
|
1062 * @return {boolean} True if the argument contains a valid authority. |
|
1063 */ |
|
1064 function isValidAuthority(authority) { |
|
1065 if (!authority) { |
|
1066 return false; |
|
1067 } |
|
1068 |
|
1069 return /^[^\s#?]+$/.test(authority); |
|
1070 } |
|
1071 |
|
1072 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path.js |
|
1073 /** |
|
1074 * Returns the path part of the URL. |
|
1075 * |
|
1076 * @param {string} url The full URL. |
|
1077 * |
|
1078 * @example |
|
1079 * ```js |
|
1080 * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test' |
|
1081 * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq' |
|
1082 * ``` |
|
1083 * |
|
1084 * @return {string|void} The path part of the URL. |
|
1085 */ |
|
1086 function getPath(url) { |
|
1087 var matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url); |
|
1088 |
|
1089 if (matches) { |
|
1090 return matches[1]; |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-path.js |
|
1095 /** |
|
1096 * Checks for invalid characters within the provided path. |
|
1097 * |
|
1098 * @param {string} path The URL path. |
|
1099 * |
|
1100 * @example |
|
1101 * ```js |
|
1102 * const isValid = isValidPath( 'test/path/' ); // true |
|
1103 * const isNotValid = isValidPath( '/invalid?test/path/' ); // false |
|
1104 * ``` |
|
1105 * |
|
1106 * @return {boolean} True if the argument contains a valid path |
|
1107 */ |
|
1108 function isValidPath(path) { |
|
1109 if (!path) { |
|
1110 return false; |
|
1111 } |
|
1112 |
|
1113 return /^[^\s#?]+$/.test(path); |
|
1114 } |
|
1115 |
|
1116 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-string.js |
|
1117 /** |
|
1118 * Returns the query string part of the URL. |
|
1119 * |
|
1120 * @param {string} url The full URL. |
|
1121 * |
|
1122 * @example |
|
1123 * ```js |
|
1124 * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true' |
|
1125 * ``` |
|
1126 * |
|
1127 * @return {string|void} The query string part of the URL. |
|
1128 */ |
|
1129 function getQueryString(url) { |
|
1130 var query; |
|
1131 |
|
1132 try { |
|
1133 query = new URL(url).search.substring(1); |
|
1134 } catch (error) {} |
|
1135 |
|
1136 if (query) { |
|
1137 return query; |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-query-string.js |
|
1142 /** |
|
1143 * Checks for invalid characters within the provided query string. |
|
1144 * |
|
1145 * @param {string} queryString The query string. |
|
1146 * |
|
1147 * @example |
|
1148 * ```js |
|
1149 * const isValid = isValidQueryString( 'query=true&another=false' ); // true |
|
1150 * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false |
|
1151 * ``` |
|
1152 * |
|
1153 * @return {boolean} True if the argument contains a valid query string. |
|
1154 */ |
|
1155 function isValidQueryString(queryString) { |
|
1156 if (!queryString) { |
|
1157 return false; |
|
1158 } |
|
1159 |
|
1160 return /^[^\s#?\/]+$/.test(queryString); |
|
1161 } |
|
1162 |
|
1163 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-path-and-query-string.js |
|
1164 /** |
|
1165 * Internal dependencies |
|
1166 */ |
|
1167 |
|
1168 /** |
|
1169 * Returns the path part and query string part of the URL. |
|
1170 * |
|
1171 * @param {string} url The full URL. |
|
1172 * |
|
1173 * @example |
|
1174 * ```js |
|
1175 * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true' |
|
1176 * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq' |
|
1177 * ``` |
|
1178 * |
|
1179 * @return {string} The path part and query string part of the URL. |
|
1180 */ |
|
1181 |
|
1182 function getPathAndQueryString(url) { |
|
1183 var path = getPath(url); |
|
1184 var queryString = getQueryString(url); |
|
1185 var value = '/'; |
|
1186 if (path) value += path; |
|
1187 if (queryString) value += "?".concat(queryString); |
|
1188 return value; |
|
1189 } |
|
1190 |
|
1191 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-fragment.js |
|
1192 /** |
|
1193 * Returns the fragment part of the URL. |
|
1194 * |
|
1195 * @param {string} url The full URL |
|
1196 * |
|
1197 * @example |
|
1198 * ```js |
|
1199 * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment' |
|
1200 * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment' |
|
1201 * ``` |
|
1202 * |
|
1203 * @return {string|void} The fragment part of the URL. |
|
1204 */ |
|
1205 function getFragment(url) { |
|
1206 var matches = /^\S+?(#[^\s\?]*)/.exec(url); |
|
1207 |
|
1208 if (matches) { |
|
1209 return matches[1]; |
|
1210 } |
|
1211 } |
|
1212 |
|
1213 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/is-valid-fragment.js |
|
1214 /** |
|
1215 * Checks for invalid characters within the provided fragment. |
|
1216 * |
|
1217 * @param {string} fragment The url fragment. |
|
1218 * |
|
1219 * @example |
|
1220 * ```js |
|
1221 * const isValid = isValidFragment( '#valid-fragment' ); // true |
|
1222 * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false |
|
1223 * ``` |
|
1224 * |
|
1225 * @return {boolean} True if the argument contains a valid fragment. |
|
1226 */ |
|
1227 function isValidFragment(fragment) { |
|
1228 if (!fragment) { |
|
1229 return false; |
|
1230 } |
|
1231 |
|
1232 return /^#[^\s#?\/]*$/.test(fragment); |
|
1233 } |
|
1234 |
|
1235 // EXTERNAL MODULE: ./node_modules/qs/lib/index.js |
|
1236 var lib = __webpack_require__(115); |
|
1237 |
|
1238 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/add-query-args.js |
|
1239 /** |
|
1240 * External dependencies |
|
1241 */ |
|
1242 |
|
1243 /** |
|
1244 * Appends arguments as querystring to the provided URL. If the URL already |
|
1245 * includes query arguments, the arguments are merged with (and take precedent |
|
1246 * over) the existing set. |
|
1247 * |
|
1248 * @param {string} [url=''] URL to which arguments should be appended. If omitted, |
|
1249 * only the resulting querystring is returned. |
|
1250 * @param {Object} [args] Query arguments to apply to URL. |
|
1251 * |
|
1252 * @example |
|
1253 * ```js |
|
1254 * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test |
|
1255 * ``` |
|
1256 * |
|
1257 * @return {string} URL with arguments applied. |
|
1258 */ |
|
1259 |
|
1260 function addQueryArgs() { |
|
1261 var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
1262 var args = arguments.length > 1 ? arguments[1] : undefined; |
|
1263 |
|
1264 // If no arguments are to be appended, return original URL. |
|
1265 if (!args || !Object.keys(args).length) { |
|
1266 return url; |
|
1267 } |
|
1268 |
|
1269 var baseUrl = url; // Determine whether URL already had query arguments. |
|
1270 |
|
1271 var queryStringIndex = url.indexOf('?'); |
|
1272 |
|
1273 if (queryStringIndex !== -1) { |
|
1274 // Merge into existing query arguments. |
|
1275 args = Object.assign(Object(lib["parse"])(url.substr(queryStringIndex + 1)), args); // Change working base URL to omit previous query arguments. |
|
1276 |
|
1277 baseUrl = baseUrl.substr(0, queryStringIndex); |
|
1278 } |
|
1279 |
|
1280 return baseUrl + '?' + Object(lib["stringify"])(args); |
|
1281 } |
|
1282 |
|
1283 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/get-query-arg.js |
|
1284 /** |
|
1285 * External dependencies |
|
1286 */ |
|
1287 |
|
1288 /* eslint-disable jsdoc/valid-types */ |
|
1289 |
|
1290 /** |
|
1291 * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject |
|
1292 */ |
|
1293 |
|
1294 /* eslint-enable */ |
|
1295 |
|
1296 /** |
|
1297 * @typedef {string|string[]|QueryArgObject} QueryArgParsed |
|
1298 */ |
|
1299 |
|
1300 /** |
|
1301 * Returns a single query argument of the url |
|
1302 * |
|
1303 * @param {string} url URL. |
|
1304 * @param {string} arg Query arg name. |
|
1305 * |
|
1306 * @example |
|
1307 * ```js |
|
1308 * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar |
|
1309 * ``` |
|
1310 * |
|
1311 * @return {QueryArgParsed|undefined} Query arg value. |
|
1312 */ |
|
1313 |
|
1314 function getQueryArg(url, arg) { |
|
1315 var queryStringIndex = url.indexOf('?'); |
|
1316 var query = queryStringIndex !== -1 ? Object(lib["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
1317 return query[arg]; |
|
1318 } |
|
1319 |
|
1320 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/has-query-arg.js |
|
1321 /** |
|
1322 * Internal dependencies |
|
1323 */ |
|
1324 |
|
1325 /** |
|
1326 * Determines whether the URL contains a given query arg. |
|
1327 * |
|
1328 * @param {string} url URL. |
|
1329 * @param {string} arg Query arg name. |
|
1330 * |
|
1331 * @example |
|
1332 * ```js |
|
1333 * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true |
|
1334 * ``` |
|
1335 * |
|
1336 * @return {boolean} Whether or not the URL contains the query arg. |
|
1337 */ |
|
1338 |
|
1339 function hasQueryArg(url, arg) { |
|
1340 return getQueryArg(url, arg) !== undefined; |
|
1341 } |
|
1342 |
|
1343 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/remove-query-args.js |
|
1344 /** |
|
1345 * External dependencies |
|
1346 */ |
|
1347 |
|
1348 /** |
|
1349 * Removes arguments from the query string of the url |
|
1350 * |
|
1351 * @param {string} url URL. |
|
1352 * @param {...string} args Query Args. |
|
1353 * |
|
1354 * @example |
|
1355 * ```js |
|
1356 * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar |
|
1357 * ``` |
|
1358 * |
|
1359 * @return {string} Updated URL. |
|
1360 */ |
|
1361 |
|
1362 function removeQueryArgs(url) { |
|
1363 var queryStringIndex = url.indexOf('?'); |
|
1364 var query = queryStringIndex !== -1 ? Object(lib["parse"])(url.substr(queryStringIndex + 1)) : {}; |
|
1365 var baseUrl = queryStringIndex !== -1 ? url.substr(0, queryStringIndex) : url; |
|
1366 |
|
1367 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
1368 args[_key - 1] = arguments[_key]; |
|
1369 } |
|
1370 |
|
1371 args.forEach(function (arg) { |
|
1372 return delete query[arg]; |
|
1373 }); |
|
1374 return baseUrl + '?' + Object(lib["stringify"])(query); |
|
1375 } |
|
1376 |
|
1377 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/prepend-http.js |
|
1378 /** |
|
1379 * Internal dependencies |
|
1380 */ |
|
1381 |
|
1382 var USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i; |
|
1383 /** |
|
1384 * Prepends "http://" to a url, if it looks like something that is meant to be a TLD. |
|
1385 * |
|
1386 * @param {string} url The URL to test. |
|
1387 * |
|
1388 * @example |
|
1389 * ```js |
|
1390 * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org |
|
1391 * ``` |
|
1392 * |
|
1393 * @return {string} The updated URL. |
|
1394 */ |
|
1395 |
|
1396 function prependHTTP(url) { |
|
1397 if (!url) { |
|
1398 return url; |
|
1399 } |
|
1400 |
|
1401 url = url.trim(); |
|
1402 |
|
1403 if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) { |
|
1404 return 'http://' + url; |
|
1405 } |
|
1406 |
|
1407 return url; |
|
1408 } |
|
1409 |
|
1410 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri.js |
|
1411 /** |
|
1412 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if |
|
1413 * `decodeURI` throws an error. |
|
1414 * |
|
1415 * @param {string} uri URI to decode. |
|
1416 * |
|
1417 * @example |
|
1418 * ```js |
|
1419 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' |
|
1420 * ``` |
|
1421 * |
|
1422 * @return {string} Decoded URI if possible. |
|
1423 */ |
|
1424 function safeDecodeURI(uri) { |
|
1425 try { |
|
1426 return decodeURI(uri); |
|
1427 } catch (uriError) { |
|
1428 return uri; |
|
1429 } |
|
1430 } |
|
1431 |
|
1432 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/safe-decode-uri-component.js |
|
1433 /** |
|
1434 * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if |
|
1435 * `decodeURIComponent` throws an error. |
|
1436 * |
|
1437 * @param {string} uriComponent URI component to decode. |
|
1438 * |
|
1439 * @return {string} Decoded URI component if possible. |
|
1440 */ |
|
1441 function safeDecodeURIComponent(uriComponent) { |
|
1442 try { |
|
1443 return decodeURIComponent(uriComponent); |
|
1444 } catch (uriComponentError) { |
|
1445 return uriComponent; |
|
1446 } |
|
1447 } |
|
1448 |
|
1449 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/filter-url-for-display.js |
|
1450 /** |
|
1451 * Returns a URL for display. |
|
1452 * |
|
1453 * @param {string} url Original URL. |
|
1454 * |
|
1455 * @example |
|
1456 * ```js |
|
1457 * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg |
|
1458 * ``` |
|
1459 * |
|
1460 * @return {string} Displayed URL. |
|
1461 */ |
|
1462 function filterURLForDisplay(url) { |
|
1463 // Remove protocol and www prefixes. |
|
1464 var filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it. |
|
1465 |
|
1466 if (filteredURL.match(/^[^\/]+\/$/)) { |
|
1467 return filteredURL.replace('/', ''); |
|
1468 } |
|
1469 |
|
1470 return filteredURL; |
|
1471 } |
|
1472 |
|
1473 // EXTERNAL MODULE: external {"this":"lodash"} |
|
1474 var external_this_lodash_ = __webpack_require__(2); |
|
1475 |
|
1476 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/clean-for-slug.js |
|
1477 /** |
|
1478 * External dependencies |
|
1479 */ |
|
1480 |
|
1481 /** |
|
1482 * Performs some basic cleanup of a string for use as a post slug. |
|
1483 * |
|
1484 * This replicates some of what `sanitize_title()` does in WordPress core, but |
|
1485 * is only designed to approximate what the slug will be. |
|
1486 * |
|
1487 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin |
|
1488 * letters. Removes combining diacritical marks. Converts whitespace, periods, |
|
1489 * and forward slashes to hyphens. Removes any remaining non-word characters |
|
1490 * except hyphens. Converts remaining string to lowercase. It does not account |
|
1491 * for octets, HTML entities, or other encoded characters. |
|
1492 * |
|
1493 * @param {string} string Title or slug to be processed. |
|
1494 * |
|
1495 * @return {string} Processed string. |
|
1496 */ |
|
1497 |
|
1498 function cleanForSlug(string) { |
|
1499 if (!string) { |
|
1500 return ''; |
|
1501 } |
|
1502 |
|
1503 return Object(external_this_lodash_["trim"])(Object(external_this_lodash_["deburr"])(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-'); |
|
1504 } |
|
1505 |
|
1506 // CONCATENATED MODULE: ./node_modules/@wordpress/url/build-module/index.js |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
1297 |
1529 |
1298 |
1530 |
1299 /***/ }) |
1531 /***/ }) |
1300 |
1532 |
1301 /******/ }); |
1533 /******/ }); |