PluginProbe
Gutenberg / 15.1.1
Gutenberg v15.1.1
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 15.1.1, at build/url/index.js

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