PluginProbe
Gutenberg / 18.9.0
Gutenberg v18.9.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / url / index.js

index.js in Gutenberg 18.9.0, at build/url/index.js

1,455 lines 33.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 4793:
5 /***/ ((module) => {
6
7 var characterMap = {
8 "À": "A",
9 "Á": "A",
10 "Â": "A",
11 "Ã": "A",
12 "Ä": "A",
13 "�
14 ": "A",
15 "": "A",
16 "": "A",
17 "": "A",
18 "": "A",
19 "": "A",
20 "Æ": "AE",
21 "": "A",
22 "": "A",
23 "Ȃ": "A",
24 "": "A",
25 "": "A",
26 "": "A",
27 "": "A",
28 "": "A",
29 "Ç": "C",
30 "": "C",
31 "È": "E",
32 "É": "E",
33 "Ê": "E",
34 "Ë": "E",
35 "": "E",
36 "": "E",
37 "": "E",
38 "": "E",
39 "": "E",
40 "Ȇ": "E",
41 "": "E",
42 "": "E",
43 "": "E",
44 "": "E",
45 "": "E",
46 "": "E",
47 "Ì": "I",
48 "Í": "I",
49 "Î": "I",
50 "Ï": "I",
51 "": "I",
52 "Ȋ": "I",
53 "": "I",
54 "": "I",
55 "Ð": "D",
56 "Ñ": "N",
57 "Ò": "O",
58 "Ó": "O",
59 "Ô": "O",
60 "Õ": "O",
61 "Ö": "O",
62 "Ø": "O",
63 "": "O",
64 "": "O",
65 "": "O",
66 "Ȏ": "O",
67 "": "O",
68 "": "O",
69 "": "O",
70 "": "O",
71 "": "O",
72 "": "O",
73 "": "O",
74 "": "O",
75 "": "O",
76 "": "O",
77 "Ù": "U",
78 "Ú": "U",
79 "Û": "U",
80 "Ü": "U",
81 "": "U",
82 "": "U",
83 "": "U",
84 "": "U",
85 "": "U",
86 "Ý": "Y",
87 "à": "a",
88 "á": "a",
89 "â": "a",
90 "ã": "a",
91 "ä": "a",
92 "å": "a",
93 "": "a",
94 "": "a",
95 "": "a",
96 "": "a",
97 "": "a",
98 "æ": "ae",
99 "": "a",
100 "": "a",
101 "ȃ": "a",
102 "": "a",
103 "": "a",
104 "": "a",
105 "": "a",
106 "": "a",
107 "ç": "c",
108 "": "c",
109 "è": "e",
110 "é": "e",
111 "ê": "e",
112 "ë": "e",
113 "ế": "e",
114 "": "e",
115 "": "e",
116 "": "e",
117 "": "e",
118 "ȇ": "e",
119 "": "e",
120 "": "e",
121 "": "e",
122 "": "e",
123 "�
124 ": "e",
125 "": "e",
126 "ì": "i",
127 "í": "i",
128 "î": "i",
129 "ï": "i",
130 "": "i",
131 "ȋ": "i",
132 "": "i",
133 "": "i",
134 "ð": "d",
135 "ñ": "n",
136 "ò": "o",
137 "ó": "o",
138 "ô": "o",
139 "õ": "o",
140 "ö": "o",
141 "ø": "o",
142 "": "o",
143 "": "o",
144 "": "o",
145 "ȏ": "o",
146 "": "o",
147 "": "o",
148 "": "o",
149 "": "o",
150 "": "o",
151 "": "o",
152 "": "o",
153 "": "o",
154 "": "o",
155 "": "o",
156 "ù": "u",
157 "ú": "u",
158 "û": "u",
159 "ü": "u",
160 "": "u",
161 "": "u",
162 "": "u",
163 "": "u",
164 "": "u",
165 "ý": "y",
166 "ÿ": "y",
167 "Ā": "A",
168 "ā": "a",
169 "Ă": "A",
170 "ă": "a",
171 "Ą": "A",
172 "�
173 ": "a",
174 "Ć": "C",
175 "ć": "c",
176 "Ĉ": "C",
177 "ĉ": "c",
178 "Ċ": "C",
179 "ċ": "c",
180 "Č": "C",
181 "č": "c",
182 "": "C",
183 "": "c",
184 "Ď": "D",
185 "ď": "d",
186 "Đ": "D",
187 "đ": "d",
188 "Ē": "E",
189 "ē": "e",
190 "Ĕ": "E",
191 "ĕ": "e",
192 "Ė": "E",
193 "ė": "e",
194 "Ę": "E",
195 "ę": "e",
196 "Ě": "E",
197 "ě": "e",
198 "Ĝ": "G",
199 "Ǵ": "G",
200 "ĝ": "g",
201 "ǵ": "g",
202 "Ğ": "G",
203 "ğ": "g",
204 "Ġ": "G",
205 "ġ": "g",
206 "Ģ": "G",
207 "ģ": "g",
208 "Ĥ": "H",
209 "ĥ": "h",
210 "Ħ": "H",
211 "ħ": "h",
212 "": "H",
213 "": "h",
214 "Ĩ": "I",
215 "ĩ": "i",
216 "Ī": "I",
217 "ī": "i",
218 "Ĭ": "I",
219 "ĭ": "i",
220 "Į": "I",
221 "į": "i",
222 "İ": "I",
223 "ı": "i",
224 "IJ": "IJ",
225 "ij": "ij",
226 "Ĵ": "J",
227 "ĵ": "j",
228 "Ķ": "K",
229 "ķ": "k",
230 "": "K",
231 "": "k",
232 "": "K",
233 "": "k",
234 "Ĺ": "L",
235 "ĺ": "l",
236 "Ļ": "L",
237 "ļ": "l",
238 "Ľ": "L",
239 "ľ": "l",
240 "Ŀ": "L",
241 "ŀ": "l",
242 "Ł": "l",
243 "ł": "l",
244 "": "M",
245 "ḿ": "m",
246 "": "M",
247 "": "m",
248 "Ń": "N",
249 "ń": "n",
250 "�
251 ": "N",
252 "ņ": "n",
253 "Ň": "N",
254 "ň": "n",
255 "ʼn": "n",
256 "": "N",
257 "": "n",
258 "Ō": "O",
259 "ō": "o",
260 "Ŏ": "O",
261 "ŏ": "o",
262 "Ő": "O",
263 "ő": "o",
264 "Œ": "OE",
265 "œ": "oe",
266 "": "P",
267 "": "p",
268 "Ŕ": "R",
269 "ŕ": "r",
270 "Ŗ": "R",
271 "ŗ": "r",
272 "Ř": "R",
273 "ř": "r",
274 "": "R",
275 "": "r",
276 "Ȓ": "R",
277 "ȓ": "r",
278 "Ś": "S",
279 "ś": "s",
280 "Ŝ": "S",
281 "ŝ": "s",
282 "Ş": "S",
283 "Ș": "S",
284 "ș": "s",
285 "ş": "s",
286 "Š": "S",
287 "š": "s",
288 "Ţ": "T",
289 "ţ": "t",
290 "ț": "t",
291 "Ț": "T",
292 "Ť": "T",
293 "ť": "t",
294 "Ŧ": "T",
295 "ŧ": "t",
296 "": "T",
297 "": "t",
298 "Ũ": "U",
299 "ũ": "u",
300 "Ū": "U",
301 "ū": "u",
302 "Ŭ": "U",
303 "ŭ": "u",
304 "Ů": "U",
305 "ů": "u",
306 "Ű": "U",
307 "ű": "u",
308 "Ų": "U",
309 "ų": "u",
310 "Ȗ": "U",
311 "ȗ": "u",
312 "": "V",
313 "": "v",
314 "Ŵ": "W",
315 "ŵ": "w",
316 "": "W",
317 "": "w",
318 "": "X",
319 "": "x",
320 "Ŷ": "Y",
321 "ŷ": "y",
322 "Ÿ": "Y",
323 "": "Y",
324 "": "y",
325 "Ź": "Z",
326 "ź": "z",
327 "Ż": "Z",
328 "ż": "z",
329 "Ž": "Z",
330 "ž": "z",
331 "ſ": "s",
332 "ƒ": "f",
333 "Ơ": "O",
334 "ơ": "o",
335 "Ư": "U",
336 "ư": "u",
337 "Ǎ": "A",
338 "ǎ": "a",
339 "Ǐ": "I",
340 "ǐ": "i",
341 "Ǒ": "O",
342 "ǒ": "o",
343 "Ǔ": "U",
344 "ǔ": "u",
345 "Ǖ": "U",
346 "ǖ": "u",
347 "Ǘ": "U",
348 "ǘ": "u",
349 "Ǚ": "U",
350 "ǚ": "u",
351 "Ǜ": "U",
352 "ǜ": "u",
353 "": "U",
354 "": "u",
355 "": "U",
356 "": "u",
357 "Ǻ": "A",
358 "ǻ": "a",
359 "Ǽ": "AE",
360 "ǽ": "ae",
361 "Ǿ": "O",
362 "ǿ": "o",
363 "Þ": "TH",
364 "þ": "th",
365 "": "P",
366 "": "p",
367 "": "S",
368 "": "s",
369 "": "X",
370 "": "x",
371 "Ѓ": "Г",
372 "ѓ": "г",
373 "Ќ": "К",
374 "ќ": "к",
375 "": "A",
376 "": "a",
377 "": "E",
378 "": "e",
379 "": "I",
380 "": "i",
381 "Ǹ": "N",
382 "ǹ": "n",
383 "": "O",
384 "": "o",
385 "": "O",
386 "": "o",
387 "": "U",
388 "": "u",
389 "": "W",
390 "": "w",
391 "": "Y",
392 "": "y",
393 "Ȁ": "A",
394 "ȁ": "a",
395 "Ȅ": "E",
396 "�
397 ": "e",
398 "Ȉ": "I",
399 "ȉ": "i",
400 "Ȍ": "O",
401 "ȍ": "o",
402 "Ȑ": "R",
403 "ȑ": "r",
404 "Ȕ": "U",
405 "ȕ": "u",
406 "": "B",
407 "": "b",
408 "Č̣": "C",
409 "č̣": "c",
410 "Ê̌": "E",
411 "ê̌": "e",
412 "": "F",
413 "": "f",
414 "Ǧ": "G",
415 "ǧ": "g",
416 "Ȟ": "H",
417 "ȟ": "h",
418 "": "J",
419 "ǰ": "j",
420 "Ǩ": "K",
421 "ǩ": "k",
422 "": "M",
423 "": "m",
424 "": "P",
425 "": "p",
426 "": "Q",
427 "": "q",
428 "Ř̩": "R",
429 "ř̩": "r",
430 "": "S",
431 "": "s",
432 "": "V",
433 "": "v",
434 "": "W",
435 "": "w",
436 "": "X",
437 "": "x",
438 "": "Y",
439 "": "y",
440 "": "A",
441 "": "a",
442 "": "B",
443 "": "b",
444 "": "D",
445 "": "d",
446 "Ȩ": "E",
447 "ȩ": "e",
448 "Ɛ̧": "E",
449 "ɛ̧": "e",
450 "": "H",
451 "": "h",
452 "": "I",
453 "": "i",
454 "Ɨ̧": "I",
455 "ɨ̧": "i",
456 "": "M",
457 "": "m",
458 "": "O",
459 "": "o",
460 "": "Q",
461 "": "q",
462 "": "U",
463 "": "u",
464 "": "X",
465 "": "x",
466 "": "Z",
467 "": "z",
468 "й":"и",
469 "Й":"И",
470 "ё":"е",
471 "Ё":"Е",
472 };
473
474 var chars = Object.keys(characterMap).join('|');
475 var allAccents = new RegExp(chars, 'g');
476 var firstAccent = new RegExp(chars, '');
477
478 function matcher(match) {
479 return characterMap[match];
480 }
481
482 var removeAccents = function(string) {
483 return string.replace(allAccents, matcher);
484 };
485
486 var hasAccents = function(string) {
487 return !!string.match(firstAccent);
488 };
489
490 module.exports = removeAccents;
491 module.exports.has = hasAccents;
492 module.exports.remove = removeAccents;
493
494
495 /***/ })
496
497 /******/ });
498 /************************************************************************/
499 /******/ // The module cache
500 /******/ var __webpack_module_cache__ = {};
501 /******/
502 /******/ // The require function
503 /******/ function __webpack_require__(moduleId) {
504 /******/ // Check if module is in cache
505 /******/ var cachedModule = __webpack_module_cache__[moduleId];
506 /******/ if (cachedModule !== undefined) {
507 /******/ return cachedModule.exports;
508 /******/ }
509 /******/ // Create a new module (and put it into the cache)
510 /******/ var module = __webpack_module_cache__[moduleId] = {
511 /******/ // no module.id needed
512 /******/ // no module.loaded needed
513 /******/ exports: {}
514 /******/ };
515 /******/
516 /******/ // Execute the module function
517 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
518 /******/
519 /******/ // Return the exports of the module
520 /******/ return module.exports;
521 /******/ }
522 /******/
523 /************************************************************************/
524 /******/ /* webpack/runtime/compat get default export */
525 /******/ (() => {
526 /******/ // getDefaultExport function for compatibility with non-harmony modules
527 /******/ __webpack_require__.n = (module) => {
528 /******/ var getter = module && module.__esModule ?
529 /******/ () => (module['default']) :
530 /******/ () => (module);
531 /******/ __webpack_require__.d(getter, { a: getter });
532 /******/ return getter;
533 /******/ };
534 /******/ })();
535 /******/
536 /******/ /* webpack/runtime/define property getters */
537 /******/ (() => {
538 /******/ // define getter functions for harmony exports
539 /******/ __webpack_require__.d = (exports, definition) => {
540 /******/ for(var key in definition) {
541 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
542 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
543 /******/ }
544 /******/ }
545 /******/ };
546 /******/ })();
547 /******/
548 /******/ /* webpack/runtime/hasOwnProperty shorthand */
549 /******/ (() => {
550 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
551 /******/ })();
552 /******/
553 /******/ /* webpack/runtime/make namespace object */
554 /******/ (() => {
555 /******/ // define __esModule on exports
556 /******/ __webpack_require__.r = (exports) => {
557 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
558 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
559 /******/ }
560 /******/ Object.defineProperty(exports, '__esModule', { value: true });
561 /******/ };
562 /******/ })();
563 /******/
564 /************************************************************************/
565 var __webpack_exports__ = {};
566 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
567 (() => {
568 "use strict";
569 // ESM COMPAT FLAG
570 __webpack_require__.r(__webpack_exports__);
571
572 // EXPORTS
573 __webpack_require__.d(__webpack_exports__, {
574 addQueryArgs: () => (/* reexport */ addQueryArgs),
575 buildQueryString: () => (/* reexport */ buildQueryString),
576 cleanForSlug: () => (/* reexport */ cleanForSlug),
577 filterURLForDisplay: () => (/* reexport */ filterURLForDisplay),
578 getAuthority: () => (/* reexport */ getAuthority),
579 getFilename: () => (/* reexport */ getFilename),
580 getFragment: () => (/* reexport */ getFragment),
581 getPath: () => (/* reexport */ getPath),
582 getPathAndQueryString: () => (/* reexport */ getPathAndQueryString),
583 getProtocol: () => (/* reexport */ getProtocol),
584 getQueryArg: () => (/* reexport */ getQueryArg),
585 getQueryArgs: () => (/* reexport */ getQueryArgs),
586 getQueryString: () => (/* reexport */ getQueryString),
587 hasQueryArg: () => (/* reexport */ hasQueryArg),
588 isEmail: () => (/* reexport */ isEmail),
589 isURL: () => (/* reexport */ isURL),
590 isValidAuthority: () => (/* reexport */ isValidAuthority),
591 isValidFragment: () => (/* reexport */ isValidFragment),
592 isValidPath: () => (/* reexport */ isValidPath),
593 isValidProtocol: () => (/* reexport */ isValidProtocol),
594 isValidQueryString: () => (/* reexport */ isValidQueryString),
595 normalizePath: () => (/* reexport */ normalizePath),
596 prependHTTP: () => (/* reexport */ prependHTTP),
597 prependHTTPS: () => (/* reexport */ prependHTTPS),
598 removeQueryArgs: () => (/* reexport */ removeQueryArgs),
599 safeDecodeURI: () => (/* reexport */ safeDecodeURI),
600 safeDecodeURIComponent: () => (/* reexport */ safeDecodeURIComponent)
601 });
602
603 ;// CONCATENATED MODULE: ./packages/url/build-module/is-url.js
604 /**
605 * Determines whether the given string looks like a URL.
606 *
607 * @param {string} url The string to scrutinise.
608 *
609 * @example
610 * ```js
611 * const isURL = isURL( 'https://wordpress.org' ); // true
612 * ```
613 *
614 * @see https://url.spec.whatwg.org/
615 * @see https://url.spec.whatwg.org/#valid-url-string
616 *
617 * @return {boolean} Whether or not it looks like a URL.
618 */
619 function isURL(url) {
620 // A URL can be considered value if the `URL` constructor is able to parse
621 // it. The constructor throws an error for an invalid URL.
622 try {
623 new URL(url);
624 return true;
625 } catch {
626 return false;
627 }
628 }
629
630 ;// CONCATENATED MODULE: ./packages/url/build-module/is-email.js
631 const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
632
633 /**
634 * Determines whether the given string looks like an email.
635 *
636 * @param {string} email The string to scrutinise.
637 *
638 * @example
639 * ```js
640 * const isEmail = isEmail( 'hello@wordpress.org' ); // true
641 * ```
642 *
643 * @return {boolean} Whether or not it looks like an email.
644 */
645 function isEmail(email) {
646 return EMAIL_REGEXP.test(email);
647 }
648
649 ;// CONCATENATED MODULE: ./packages/url/build-module/get-protocol.js
650 /**
651 * Returns the protocol part of the URL.
652 *
653 * @param {string} url The full URL.
654 *
655 * @example
656 * ```js
657 * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'
658 * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'
659 * ```
660 *
661 * @return {string|void} The protocol part of the URL.
662 */
663 function getProtocol(url) {
664 const matches = /^([^\s:]+:)/.exec(url);
665 if (matches) {
666 return matches[1];
667 }
668 }
669
670 ;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-protocol.js
671 /**
672 * Tests if a url protocol is valid.
673 *
674 * @param {string} protocol The url protocol.
675 *
676 * @example
677 * ```js
678 * const isValid = isValidProtocol( 'https:' ); // true
679 * const isNotValid = isValidProtocol( 'https :' ); // false
680 * ```
681 *
682 * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:).
683 */
684 function isValidProtocol(protocol) {
685 if (!protocol) {
686 return false;
687 }
688 return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol);
689 }
690
691 ;// CONCATENATED MODULE: ./packages/url/build-module/get-authority.js
692 /**
693 * Returns the authority part of the URL.
694 *
695 * @param {string} url The full URL.
696 *
697 * @example
698 * ```js
699 * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'
700 * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
701 * ```
702 *
703 * @return {string|void} The authority part of the URL.
704 */
705 function getAuthority(url) {
706 const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
707 if (matches) {
708 return matches[1];
709 }
710 }
711
712 ;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-authority.js
713 /**
714 * Checks for invalid characters within the provided authority.
715 *
716 * @param {string} authority A string containing the URL authority.
717 *
718 * @example
719 * ```js
720 * const isValid = isValidAuthority( 'wordpress.org' ); // true
721 * const isNotValid = isValidAuthority( 'wordpress#org' ); // false
722 * ```
723 *
724 * @return {boolean} True if the argument contains a valid authority.
725 */
726 function isValidAuthority(authority) {
727 if (!authority) {
728 return false;
729 }
730 return /^[^\s#?]+$/.test(authority);
731 }
732
733 ;// CONCATENATED MODULE: ./packages/url/build-module/get-path.js
734 /**
735 * Returns the path part of the URL.
736 *
737 * @param {string} url The full URL.
738 *
739 * @example
740 * ```js
741 * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'
742 * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'
743 * ```
744 *
745 * @return {string|void} The path part of the URL.
746 */
747 function getPath(url) {
748 const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
749 if (matches) {
750 return matches[1];
751 }
752 }
753
754 ;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-path.js
755 /**
756 * Checks for invalid characters within the provided path.
757 *
758 * @param {string} path The URL path.
759 *
760 * @example
761 * ```js
762 * const isValid = isValidPath( 'test/path/' ); // true
763 * const isNotValid = isValidPath( '/invalid?test/path/' ); // false
764 * ```
765 *
766 * @return {boolean} True if the argument contains a valid path
767 */
768 function isValidPath(path) {
769 if (!path) {
770 return false;
771 }
772 return /^[^\s#?]+$/.test(path);
773 }
774
775 ;// CONCATENATED MODULE: ./packages/url/build-module/get-query-string.js
776 /**
777 * Returns the query string part of the URL.
778 *
779 * @param {string} url The full URL.
780 *
781 * @example
782 * ```js
783 * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
784 * ```
785 *
786 * @return {string|void} The query string part of the URL.
787 */
788 function getQueryString(url) {
789 let query;
790 try {
791 query = new URL(url, 'http://example.com').search.substring(1);
792 } catch (error) {}
793 if (query) {
794 return query;
795 }
796 }
797
798 ;// CONCATENATED MODULE: ./packages/url/build-module/build-query-string.js
799 /**
800 * Generates URL-encoded query string using input query data.
801 *
802 * It is intended to behave equivalent as PHP's `http_build_query`, configured
803 * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).
804 *
805 * @example
806 * ```js
807 * const queryString = buildQueryString( {
808 * simple: 'is ok',
809 * arrays: [ 'are', 'fine', 'too' ],
810 * objects: {
811 * evenNested: {
812 * ok: 'yes',
813 * },
814 * },
815 * } );
816 * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
817 * ```
818 *
819 * @param {Record<string,*>} data Data to encode.
820 *
821 * @return {string} Query string.
822 */
823 function buildQueryString(data) {
824 let string = '';
825 const stack = Object.entries(data);
826 let pair;
827 while (pair = stack.shift()) {
828 let [key, value] = pair;
829
830 // Support building deeply nested data, from array or object values.
831 const hasNestedData = Array.isArray(value) || value && value.constructor === Object;
832 if (hasNestedData) {
833 // Push array or object values onto the stack as composed of their
834 // original key and nested index or key, retaining order by a
835 // combination of Array#reverse and Array#unshift onto the stack.
836 const valuePairs = Object.entries(value).reverse();
837 for (const [member, memberValue] of valuePairs) {
838 stack.unshift([`${key}[${member}]`, memberValue]);
839 }
840 } else if (value !== undefined) {
841 // Null is treated as special case, equivalent to empty string.
842 if (value === null) {
843 value = '';
844 }
845 string += '&' + [key, value].map(encodeURIComponent).join('=');
846 }
847 }
848
849 // Loop will concatenate with leading `&`, but it's only expected for all
850 // but the first query parameter. This strips the leading `&`, while still
851 // accounting for the case that the string may in-fact be empty.
852 return string.substr(1);
853 }
854
855 ;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-query-string.js
856 /**
857 * Checks for invalid characters within the provided query string.
858 *
859 * @param {string} queryString The query string.
860 *
861 * @example
862 * ```js
863 * const isValid = isValidQueryString( 'query=true&another=false' ); // true
864 * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false
865 * ```
866 *
867 * @return {boolean} True if the argument contains a valid query string.
868 */
869 function isValidQueryString(queryString) {
870 if (!queryString) {
871 return false;
872 }
873 return /^[^\s#?\/]+$/.test(queryString);
874 }
875
876 ;// CONCATENATED MODULE: ./packages/url/build-module/get-path-and-query-string.js
877 /**
878 * Internal dependencies
879 */
880
881
882 /**
883 * Returns the path part and query string part of the URL.
884 *
885 * @param {string} url The full URL.
886 *
887 * @example
888 * ```js
889 * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
890 * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
891 * ```
892 *
893 * @return {string} The path part and query string part of the URL.
894 */
895 function getPathAndQueryString(url) {
896 const path = getPath(url);
897 const queryString = getQueryString(url);
898 let value = '/';
899 if (path) {
900 value += path;
901 }
902 if (queryString) {
903 value += `?${queryString}`;
904 }
905 return value;
906 }
907
908 ;// CONCATENATED MODULE: ./packages/url/build-module/get-fragment.js
909 /**
910 * Returns the fragment part of the URL.
911 *
912 * @param {string} url The full URL
913 *
914 * @example
915 * ```js
916 * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
917 * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
918 * ```
919 *
920 * @return {string|void} The fragment part of the URL.
921 */
922 function getFragment(url) {
923 const matches = /^\S+?(#[^\s\?]*)/.exec(url);
924 if (matches) {
925 return matches[1];
926 }
927 }
928
929 ;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-fragment.js
930 /**
931 * Checks for invalid characters within the provided fragment.
932 *
933 * @param {string} fragment The url fragment.
934 *
935 * @example
936 * ```js
937 * const isValid = isValidFragment( '#valid-fragment' ); // true
938 * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
939 * ```
940 *
941 * @return {boolean} True if the argument contains a valid fragment.
942 */
943 function isValidFragment(fragment) {
944 if (!fragment) {
945 return false;
946 }
947 return /^#[^\s#?\/]*$/.test(fragment);
948 }
949
950 ;// CONCATENATED MODULE: ./packages/url/build-module/safe-decode-uri-component.js
951 /**
952 * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
953 * `decodeURIComponent` throws an error.
954 *
955 * @param {string} uriComponent URI component to decode.
956 *
957 * @return {string} Decoded URI component if possible.
958 */
959 function safeDecodeURIComponent(uriComponent) {
960 try {
961 return decodeURIComponent(uriComponent);
962 } catch (uriComponentError) {
963 return uriComponent;
964 }
965 }
966
967 ;// CONCATENATED MODULE: ./packages/url/build-module/get-query-args.js
968 /**
969 * Internal dependencies
970 */
971
972
973
974 /** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */
975
976 /**
977 * @typedef {Record<string,QueryArgParsed>} QueryArgs
978 */
979
980 /**
981 * Sets a value in object deeply by a given array of path segments. Mutates the
982 * object reference.
983 *
984 * @param {Record<string,*>} object Object in which to assign.
985 * @param {string[]} path Path segment at which to set value.
986 * @param {*} value Value to set.
987 */
988 function setPath(object, path, value) {
989 const length = path.length;
990 const lastIndex = length - 1;
991 for (let i = 0; i < length; i++) {
992 let key = path[i];
993 if (!key && Array.isArray(object)) {
994 // If key is empty string and next value is array, derive key from
995 // the current length of the array.
996 key = object.length.toString();
997 }
998 key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key;
999
1000 // If the next key in the path is numeric (or empty string), it will be
1001 // created as an array. Otherwise, it will be created as an object.
1002 const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
1003 object[key] = i === lastIndex ?
1004 // If at end of path, assign the intended value.
1005 value :
1006 // Otherwise, advance to the next object in the path, creating
1007 // it if it does not yet exist.
1008 object[key] || (isNextKeyArrayIndex ? [] : {});
1009 if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
1010 // If we current key is non-numeric, but the next value is an
1011 // array, coerce the value to an object.
1012 object[key] = {
1013 ...object[key]
1014 };
1015 }
1016
1017 // Update working reference object to the next in the path.
1018 object = object[key];
1019 }
1020 }
1021
1022 /**
1023 * Returns an object of query arguments of the given URL. If the given URL is
1024 * invalid or has no querystring, an empty object is returned.
1025 *
1026 * @param {string} url URL.
1027 *
1028 * @example
1029 * ```js
1030 * const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );
1031 * // { "foo": "bar", "bar": "baz" }
1032 * ```
1033 *
1034 * @return {QueryArgs} Query args object.
1035 */
1036 function getQueryArgs(url) {
1037 return (getQueryString(url) || ''
1038 // Normalize space encoding, accounting for PHP URL encoding
1039 // corresponding to `application/x-www-form-urlencoded`.
1040 //
1041 // See: https://tools.ietf.org/html/rfc1866#section-8.2.1
1042 ).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => {
1043 const [key, value = ''] = keyValue.split('=')
1044 // Filtering avoids decoding as `undefined` for value, where
1045 // default is restored in destructuring assignment.
1046 .filter(Boolean).map(safeDecodeURIComponent);
1047 if (key) {
1048 const segments = key.replace(/\]/g, '').split('[');
1049 setPath(accumulator, segments, value);
1050 }
1051 return accumulator;
1052 }, Object.create(null));
1053 }
1054
1055 ;// CONCATENATED MODULE: ./packages/url/build-module/add-query-args.js
1056 /**
1057 * Internal dependencies
1058 */
1059
1060
1061
1062 /**
1063 * Appends arguments as querystring to the provided URL. If the URL already
1064 * includes query arguments, the arguments are merged with (and take precedent
1065 * over) the existing set.
1066 *
1067 * @param {string} [url=''] URL to which arguments should be appended. If omitted,
1068 * only the resulting querystring is returned.
1069 * @param {Object} [args] Query arguments to apply to URL.
1070 *
1071 * @example
1072 * ```js
1073 * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
1074 * ```
1075 *
1076 * @return {string} URL with arguments applied.
1077 */
1078 function addQueryArgs(url = '', args) {
1079 // If no arguments are to be appended, return original URL.
1080 if (!args || !Object.keys(args).length) {
1081 return url;
1082 }
1083 let baseUrl = url;
1084
1085 // Determine whether URL already had query arguments.
1086 const queryStringIndex = url.indexOf('?');
1087 if (queryStringIndex !== -1) {
1088 // Merge into existing query arguments.
1089 args = Object.assign(getQueryArgs(url), args);
1090
1091 // Change working base URL to omit previous query arguments.
1092 baseUrl = baseUrl.substr(0, queryStringIndex);
1093 }
1094 return baseUrl + '?' + buildQueryString(args);
1095 }
1096
1097 ;// CONCATENATED MODULE: ./packages/url/build-module/get-query-arg.js
1098 /**
1099 * Internal dependencies
1100 */
1101
1102
1103 /**
1104 * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
1105 */
1106
1107 /**
1108 * @typedef {string|string[]|QueryArgObject} QueryArgParsed
1109 */
1110
1111 /**
1112 * Returns a single query argument of the url
1113 *
1114 * @param {string} url URL.
1115 * @param {string} arg Query arg name.
1116 *
1117 * @example
1118 * ```js
1119 * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar
1120 * ```
1121 *
1122 * @return {QueryArgParsed|void} Query arg value.
1123 */
1124 function getQueryArg(url, arg) {
1125 return getQueryArgs(url)[arg];
1126 }
1127
1128 ;// CONCATENATED MODULE: ./packages/url/build-module/has-query-arg.js
1129 /**
1130 * Internal dependencies
1131 */
1132
1133
1134 /**
1135 * Determines whether the URL contains a given query arg.
1136 *
1137 * @param {string} url URL.
1138 * @param {string} arg Query arg name.
1139 *
1140 * @example
1141 * ```js
1142 * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
1143 * ```
1144 *
1145 * @return {boolean} Whether or not the URL contains the query arg.
1146 */
1147 function hasQueryArg(url, arg) {
1148 return getQueryArg(url, arg) !== undefined;
1149 }
1150
1151 ;// CONCATENATED MODULE: ./packages/url/build-module/remove-query-args.js
1152 /**
1153 * Internal dependencies
1154 */
1155
1156
1157
1158 /**
1159 * Removes arguments from the query string of the url
1160 *
1161 * @param {string} url URL.
1162 * @param {...string} args Query Args.
1163 *
1164 * @example
1165 * ```js
1166 * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
1167 * ```
1168 *
1169 * @return {string} Updated URL.
1170 */
1171 function removeQueryArgs(url, ...args) {
1172 const queryStringIndex = url.indexOf('?');
1173 if (queryStringIndex === -1) {
1174 return url;
1175 }
1176 const query = getQueryArgs(url);
1177 const baseURL = url.substr(0, queryStringIndex);
1178 args.forEach(arg => delete query[arg]);
1179 const queryString = buildQueryString(query);
1180 return queryString ? baseURL + '?' + queryString : baseURL;
1181 }
1182
1183 ;// CONCATENATED MODULE: ./packages/url/build-module/prepend-http.js
1184 /**
1185 * Internal dependencies
1186 */
1187
1188 const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
1189
1190 /**
1191 * Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
1192 *
1193 * @param {string} url The URL to test.
1194 *
1195 * @example
1196 * ```js
1197 * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org
1198 * ```
1199 *
1200 * @return {string} The updated URL.
1201 */
1202 function prependHTTP(url) {
1203 if (!url) {
1204 return url;
1205 }
1206 url = url.trim();
1207 if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
1208 return 'http://' + url;
1209 }
1210 return url;
1211 }
1212
1213 ;// CONCATENATED MODULE: ./packages/url/build-module/safe-decode-uri.js
1214 /**
1215 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
1216 * `decodeURI` throws an error.
1217 *
1218 * @param {string} uri URI to decode.
1219 *
1220 * @example
1221 * ```js
1222 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
1223 * ```
1224 *
1225 * @return {string} Decoded URI if possible.
1226 */
1227 function safeDecodeURI(uri) {
1228 try {
1229 return decodeURI(uri);
1230 } catch (uriError) {
1231 return uri;
1232 }
1233 }
1234
1235 ;// CONCATENATED MODULE: ./packages/url/build-module/filter-url-for-display.js
1236 /**
1237 * Returns a URL for display.
1238 *
1239 * @param {string} url Original URL.
1240 * @param {number|null} maxLength URL length.
1241 *
1242 * @example
1243 * ```js
1244 * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
1245 * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
1246 * ```
1247 *
1248 * @return {string} Displayed URL.
1249 */
1250 function filterURLForDisplay(url, maxLength = null) {
1251 if (!url) {
1252 return '';
1253 }
1254
1255 // Remove protocol and www prefixes.
1256 let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, '').replace(/^www\./i, '');
1257
1258 // Ends with / and only has that single slash, strip it.
1259 if (filteredURL.match(/^[^\/]+\/$/)) {
1260 filteredURL = filteredURL.replace('/', '');
1261 }
1262
1263 // capture file name from URL
1264 const fileRegexp = /\/([^\/?]+)\.(?:[\w]+)(?=\?|$)/;
1265 if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(fileRegexp)) {
1266 return filteredURL;
1267 }
1268
1269 // If the file is not greater than max length, return last portion of URL.
1270 filteredURL = filteredURL.split('?')[0];
1271 const urlPieces = filteredURL.split('/');
1272 const file = urlPieces[urlPieces.length - 1];
1273 if (file.length <= maxLength) {
1274 return '' + filteredURL.slice(-maxLength);
1275 }
1276
1277 // If the file is greater than max length, truncate the file.
1278 const index = file.lastIndexOf('.');
1279 const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)];
1280 const truncatedFile = fileName.slice(-3) + '.' + extension;
1281 return file.slice(0, maxLength - truncatedFile.length - 1) + '' + truncatedFile;
1282 }
1283
1284 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
1285 var remove_accents = __webpack_require__(4793);
1286 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
1287 ;// CONCATENATED MODULE: ./packages/url/build-module/clean-for-slug.js
1288 /**
1289 * External dependencies
1290 */
1291
1292
1293 /**
1294 * Performs some basic cleanup of a string for use as a post slug.
1295 *
1296 * This replicates some of what `sanitize_title()` does in WordPress core, but
1297 * is only designed to approximate what the slug will be.
1298 *
1299 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin
1300 * letters. Removes combining diacritical marks. Converts whitespace, periods,
1301 * and forward slashes to hyphens. Removes any remaining non-word characters
1302 * except hyphens. Converts remaining string to lowercase. It does not account
1303 * for octets, HTML entities, or other encoded characters.
1304 *
1305 * @param {string} string Title or slug to be processed.
1306 *
1307 * @return {string} Processed string.
1308 */
1309 function cleanForSlug(string) {
1310 if (!string) {
1311 return '';
1312 }
1313 return remove_accents_default()(string)
1314 // Convert each group of whitespace, periods, and forward slashes to a hyphen.
1315 .replace(/[\s\./]+/g, '-')
1316 // Remove anything that's not a letter, number, underscore or hyphen.
1317 .replace(/[^\p{L}\p{N}_-]+/gu, '')
1318 // Convert to lowercase
1319 .toLowerCase()
1320 // Replace multiple hyphens with a single one.
1321 .replace(/-+/g, '-')
1322 // Remove any remaining leading or trailing hyphens.
1323 .replace(/(^-+)|(-+$)/g, '');
1324 }
1325
1326 ;// CONCATENATED MODULE: ./packages/url/build-module/get-filename.js
1327 /**
1328 * Returns the filename part of the URL.
1329 *
1330 * @param {string} url The full URL.
1331 *
1332 * @example
1333 * ```js
1334 * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'
1335 * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
1336 * ```
1337 *
1338 * @return {string|void} The filename part of the URL.
1339 */
1340 function getFilename(url) {
1341 let filename;
1342 if (!url) {
1343 return;
1344 }
1345 try {
1346 filename = new URL(url, 'http://example.com').pathname.split('/').pop();
1347 } catch (error) {}
1348 if (filename) {
1349 return filename;
1350 }
1351 }
1352
1353 ;// CONCATENATED MODULE: ./packages/url/build-module/normalize-path.js
1354 /**
1355 * Given a path, returns a normalized path where equal query parameter values
1356 * will be treated as identical, regardless of order they appear in the original
1357 * text.
1358 *
1359 * @param {string} path Original path.
1360 *
1361 * @return {string} Normalized path.
1362 */
1363 function normalizePath(path) {
1364 const splitted = path.split('?');
1365 const query = splitted[1];
1366 const base = splitted[0];
1367 if (!query) {
1368 return base;
1369 }
1370
1371 // 'b=1%2C2&c=2&a=5'
1372 return base + '?' + query
1373 // [ 'b=1%2C2', 'c=2', 'a=5' ]
1374 .split('&')
1375 // [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]
1376 .map(entry => entry.split('='))
1377 // [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]
1378 .map(pair => pair.map(decodeURIComponent))
1379 // [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]
1380 .sort((a, b) => a[0].localeCompare(b[0]))
1381 // [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]
1382 .map(pair => pair.map(encodeURIComponent))
1383 // [ 'a=5', 'b=1%2C2', 'c=2' ]
1384 .map(pair => pair.join('='))
1385 // 'a=5&b=1%2C2&c=2'
1386 .join('&');
1387 }
1388
1389 ;// CONCATENATED MODULE: ./packages/url/build-module/prepend-https.js
1390 /**
1391 * Internal dependencies
1392 */
1393
1394
1395 /**
1396 * Prepends "https://" to a url, if it looks like something that is meant to be a TLD.
1397 *
1398 * Note: this will not replace "http://" with "https://".
1399 *
1400 * @param {string} url The URL to test.
1401 *
1402 * @example
1403 * ```js
1404 * const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org
1405 * ```
1406 *
1407 * @return {string} The updated URL.
1408 */
1409 function prependHTTPS(url) {
1410 if (!url) {
1411 return url;
1412 }
1413
1414 // If url starts with http://, return it as is.
1415 if (url.startsWith('http://')) {
1416 return url;
1417 }
1418 url = prependHTTP(url);
1419 return url.replace(/^http:/, 'https:');
1420 }
1421
1422 ;// CONCATENATED MODULE: ./packages/url/build-module/index.js
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451 })();
1452
1453 (window.wp = window.wp || {}).url = __webpack_exports__;
1454 /******/ })()
1455 ;