PluginProbe
Gutenberg / 10.1.0
Gutenberg v10.1.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
← All changes | build/url/index.js +1 -887 12.6.0 → 10.1.0 View file →
@@ -1,887 +1 @@
1 -/******/ (function() { // webpackBootstrap
2 -/******/ "use strict";
3 -/******/ // The require scope
4 -/******/ var __webpack_require__ = {};
5 -/******/
6 -/************************************************************************/
7 -/******/ /* webpack/runtime/define property getters */
8 -/******/ !function() {
9 -/******/ // define getter functions for harmony exports
10 -/******/ __webpack_require__.d = function(exports, definition) {
11 -/******/ for(var key in definition) {
12 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 -/******/ }
15 -/******/ }
16 -/******/ };
17 -/******/ }();
18 -/******/
19 -/******/ /* webpack/runtime/hasOwnProperty shorthand */
20 -/******/ !function() {
21 -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
22 -/******/ }();
23 -/******/
24 -/******/ /* webpack/runtime/make namespace object */
25 -/******/ !function() {
26 -/******/ // define __esModule on exports
27 -/******/ __webpack_require__.r = function(exports) {
28 -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29 -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30 -/******/ }
31 -/******/ Object.defineProperty(exports, '__esModule', { value: true });
32 -/******/ };
33 -/******/ }();
34 -/******/
35 -/************************************************************************/
36 -var __webpack_exports__ = {};
37 -// ESM COMPAT FLAG
38 -__webpack_require__.r(__webpack_exports__);
39 -
40 -// EXPORTS
41 -__webpack_require__.d(__webpack_exports__, {
42 - "addQueryArgs": function() { return /* reexport */ addQueryArgs; },
43 - "buildQueryString": function() { return /* reexport */ buildQueryString; },
44 - "cleanForSlug": function() { return /* reexport */ cleanForSlug; },
45 - "filterURLForDisplay": function() { return /* reexport */ filterURLForDisplay; },
46 - "getAuthority": function() { return /* reexport */ getAuthority; },
47 - "getFilename": function() { return /* reexport */ getFilename; },
48 - "getFragment": function() { return /* reexport */ getFragment; },
49 - "getPath": function() { return /* reexport */ getPath; },
50 - "getPathAndQueryString": function() { return /* reexport */ getPathAndQueryString; },
51 - "getProtocol": function() { return /* reexport */ getProtocol; },
52 - "getQueryArg": function() { return /* reexport */ getQueryArg; },
53 - "getQueryArgs": function() { return /* reexport */ getQueryArgs; },
54 - "getQueryString": function() { return /* reexport */ getQueryString; },
55 - "hasQueryArg": function() { return /* reexport */ hasQueryArg; },
56 - "isEmail": function() { return /* reexport */ isEmail; },
57 - "isURL": function() { return /* reexport */ isURL; },
58 - "isValidAuthority": function() { return /* reexport */ isValidAuthority; },
59 - "isValidFragment": function() { return /* reexport */ isValidFragment; },
60 - "isValidPath": function() { return /* reexport */ isValidPath; },
61 - "isValidProtocol": function() { return /* reexport */ isValidProtocol; },
62 - "isValidQueryString": function() { return /* reexport */ isValidQueryString; },
63 - "normalizePath": function() { return /* reexport */ normalizePath; },
64 - "prependHTTP": function() { return /* reexport */ prependHTTP; },
65 - "removeQueryArgs": function() { return /* reexport */ removeQueryArgs; },
66 - "safeDecodeURI": function() { return /* reexport */ safeDecodeURI; },
67 - "safeDecodeURIComponent": function() { return /* reexport */ safeDecodeURIComponent; }
68 -});
69 -
70 -;// CONCATENATED MODULE: ./packages/url/build-module/is-url.js
71 -/**
72 - * Determines whether the given string looks like a URL.
73 - *
74 - * @param {string} url The string to scrutinise.
75 - *
76 - * @example
77 - * ```js
78 - * const isURL = isURL( 'https://wordpress.org' ); // true
79 - * ```
80 - *
81 - * @see https://url.spec.whatwg.org/
82 - * @see https://url.spec.whatwg.org/#valid-url-string
83 - *
84 - * @return {boolean} Whether or not it looks like a URL.
85 - */
86 -function isURL(url) {
87 - // A URL can be considered value if the `URL` constructor is able to parse
88 - // it. The constructor throws an error for an invalid URL.
89 - try {
90 - new URL(url);
91 - return true;
92 - } catch {
93 - return false;
94 - }
95 -}
96 -//# sourceMappingURL=is-url.js.map
97 -;// CONCATENATED MODULE: ./packages/url/build-module/is-email.js
98 -const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
99 -/**
100 - * Determines whether the given string looks like an email.
101 - *
102 - * @param {string} email The string to scrutinise.
103 - *
104 - * @example
105 - * ```js
106 - * const isEmail = isEmail( '[email protected]' ); // true
107 - * ```
108 - *
109 - * @return {boolean} Whether or not it looks like an email.
110 - */
111 -
112 -function isEmail(email) {
113 - return EMAIL_REGEXP.test(email);
114 -}
115 -//# sourceMappingURL=is-email.js.map
116 -;// CONCATENATED MODULE: ./packages/url/build-module/get-protocol.js
117 -/**
118 - * Returns the protocol part of the URL.
119 - *
120 - * @param {string} url The full URL.
121 - *
122 - * @example
123 - * ```js
124 - * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'
125 - * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'
126 - * ```
127 - *
128 - * @return {string|void} The protocol part of the URL.
129 - */
130 -function getProtocol(url) {
131 - const matches = /^([^\s:]+:)/.exec(url);
132 -
133 - if (matches) {
134 - return matches[1];
135 - }
136 -}
137 -//# sourceMappingURL=get-protocol.js.map
138 -;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-protocol.js
139 -/**
140 - * Tests if a url protocol is valid.
141 - *
142 - * @param {string} protocol The url protocol.
143 - *
144 - * @example
145 - * ```js
146 - * const isValid = isValidProtocol( 'https:' ); // true
147 - * const isNotValid = isValidProtocol( 'https :' ); // false
148 - * ```
149 - *
150 - * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:).
151 - */
152 -function isValidProtocol(protocol) {
153 - if (!protocol) {
154 - return false;
155 - }
156 -
157 - return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol);
158 -}
159 -//# sourceMappingURL=is-valid-protocol.js.map
160 -;// CONCATENATED MODULE: ./packages/url/build-module/get-authority.js
161 -/**
162 - * Returns the authority part of the URL.
163 - *
164 - * @param {string} url The full URL.
165 - *
166 - * @example
167 - * ```js
168 - * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'
169 - * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
170 - * ```
171 - *
172 - * @return {string|void} The authority part of the URL.
173 - */
174 -function getAuthority(url) {
175 - const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
176 -
177 - if (matches) {
178 - return matches[1];
179 - }
180 -}
181 -//# sourceMappingURL=get-authority.js.map
182 -;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-authority.js
183 -/**
184 - * Checks for invalid characters within the provided authority.
185 - *
186 - * @param {string} authority A string containing the URL authority.
187 - *
188 - * @example
189 - * ```js
190 - * const isValid = isValidAuthority( 'wordpress.org' ); // true
191 - * const isNotValid = isValidAuthority( 'wordpress#org' ); // false
192 - * ```
193 - *
194 - * @return {boolean} True if the argument contains a valid authority.
195 - */
196 -function isValidAuthority(authority) {
197 - if (!authority) {
198 - return false;
199 - }
200 -
201 - return /^[^\s#?]+$/.test(authority);
202 -}
203 -//# sourceMappingURL=is-valid-authority.js.map
204 -;// CONCATENATED MODULE: ./packages/url/build-module/get-path.js
205 -/**
206 - * Returns the path part of the URL.
207 - *
208 - * @param {string} url The full URL.
209 - *
210 - * @example
211 - * ```js
212 - * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'
213 - * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'
214 - * ```
215 - *
216 - * @return {string|void} The path part of the URL.
217 - */
218 -function getPath(url) {
219 - const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
220 -
221 - if (matches) {
222 - return matches[1];
223 - }
224 -}
225 -//# sourceMappingURL=get-path.js.map
226 -;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-path.js
227 -/**
228 - * Checks for invalid characters within the provided path.
229 - *
230 - * @param {string} path The URL path.
231 - *
232 - * @example
233 - * ```js
234 - * const isValid = isValidPath( 'test/path/' ); // true
235 - * const isNotValid = isValidPath( '/invalid?test/path/' ); // false
236 - * ```
237 - *
238 - * @return {boolean} True if the argument contains a valid path
239 - */
240 -function isValidPath(path) {
241 - if (!path) {
242 - return false;
243 - }
244 -
245 - return /^[^\s#?]+$/.test(path);
246 -}
247 -//# sourceMappingURL=is-valid-path.js.map
248 -;// CONCATENATED MODULE: ./packages/url/build-module/get-query-string.js
249 -/**
250 - * Returns the query string part of the URL.
251 - *
252 - * @param {string} url The full URL.
253 - *
254 - * @example
255 - * ```js
256 - * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
257 - * ```
258 - *
259 - * @return {string|void} The query string part of the URL.
260 - */
261 -function getQueryString(url) {
262 - let query;
263 -
264 - try {
265 - query = new URL(url, 'http://example.com').search.substring(1);
266 - } catch (error) {}
267 -
268 - if (query) {
269 - return query;
270 - }
271 -}
272 -//# sourceMappingURL=get-query-string.js.map
273 -;// CONCATENATED MODULE: ./packages/url/build-module/build-query-string.js
274 -/**
275 - * Generates URL-encoded query string using input query data.
276 - *
277 - * It is intended to behave equivalent as PHP's `http_build_query`, configured
278 - * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).
279 - *
280 - * @example
281 - * ```js
282 - * const queryString = buildQueryString( {
283 - * simple: 'is ok',
284 - * arrays: [ 'are', 'fine', 'too' ],
285 - * objects: {
286 - * evenNested: {
287 - * ok: 'yes',
288 - * },
289 - * },
290 - * } );
291 - * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
292 - * ```
293 - *
294 - * @param {Record<string,*>} data Data to encode.
295 - *
296 - * @return {string} Query string.
297 - */
298 -function buildQueryString(data) {
299 - let string = '';
300 - const stack = Object.entries(data);
301 - let pair;
302 -
303 - while (pair = stack.shift()) {
304 - let [key, value] = pair; // Support building deeply nested data, from array or object values.
305 -
306 - const hasNestedData = Array.isArray(value) || value && value.constructor === Object;
307 -
308 - if (hasNestedData) {
309 - // Push array or object values onto the stack as composed of their
310 - // original key and nested index or key, retaining order by a
311 - // combination of Array#reverse and Array#unshift onto the stack.
312 - const valuePairs = Object.entries(value).reverse();
313 -
314 - for (const [member, memberValue] of valuePairs) {
315 - stack.unshift([`${key}[${member}]`, memberValue]);
316 - }
317 - } else if (value !== undefined) {
318 - // Null is treated as special case, equivalent to empty string.
319 - if (value === null) {
320 - value = '';
321 - }
322 -
323 - string += '&' + [key, value].map(encodeURIComponent).join('=');
324 - }
325 - } // Loop will concatenate with leading `&`, but it's only expected for all
326 - // but the first query parameter. This strips the leading `&`, while still
327 - // accounting for the case that the string may in-fact be empty.
328 -
329 -
330 - return string.substr(1);
331 -}
332 -//# sourceMappingURL=build-query-string.js.map
333 -;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-query-string.js
334 -/**
335 - * Checks for invalid characters within the provided query string.
336 - *
337 - * @param {string} queryString The query string.
338 - *
339 - * @example
340 - * ```js
341 - * const isValid = isValidQueryString( 'query=true&another=false' ); // true
342 - * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false
343 - * ```
344 - *
345 - * @return {boolean} True if the argument contains a valid query string.
346 - */
347 -function isValidQueryString(queryString) {
348 - if (!queryString) {
349 - return false;
350 - }
351 -
352 - return /^[^\s#?\/]+$/.test(queryString);
353 -}
354 -//# sourceMappingURL=is-valid-query-string.js.map
355 -;// CONCATENATED MODULE: ./packages/url/build-module/get-path-and-query-string.js
356 -/**
357 - * Internal dependencies
358 - */
359 -
360 -/**
361 - * Returns the path part and query string part of the URL.
362 - *
363 - * @param {string} url The full URL.
364 - *
365 - * @example
366 - * ```js
367 - * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
368 - * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
369 - * ```
370 - *
371 - * @return {string} The path part and query string part of the URL.
372 - */
373 -
374 -function getPathAndQueryString(url) {
375 - const path = getPath(url);
376 - const queryString = getQueryString(url);
377 - let value = '/';
378 - if (path) value += path;
379 - if (queryString) value += `?${queryString}`;
380 - return value;
381 -}
382 -//# sourceMappingURL=get-path-and-query-string.js.map
383 -;// CONCATENATED MODULE: ./packages/url/build-module/get-fragment.js
384 -/**
385 - * Returns the fragment part of the URL.
386 - *
387 - * @param {string} url The full URL
388 - *
389 - * @example
390 - * ```js
391 - * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
392 - * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
393 - * ```
394 - *
395 - * @return {string|void} The fragment part of the URL.
396 - */
397 -function getFragment(url) {
398 - const matches = /^\S+?(#[^\s\?]*)/.exec(url);
399 -
400 - if (matches) {
401 - return matches[1];
402 - }
403 -}
404 -//# sourceMappingURL=get-fragment.js.map
405 -;// CONCATENATED MODULE: ./packages/url/build-module/is-valid-fragment.js
406 -/**
407 - * Checks for invalid characters within the provided fragment.
408 - *
409 - * @param {string} fragment The url fragment.
410 - *
411 - * @example
412 - * ```js
413 - * const isValid = isValidFragment( '#valid-fragment' ); // true
414 - * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
415 - * ```
416 - *
417 - * @return {boolean} True if the argument contains a valid fragment.
418 - */
419 -function isValidFragment(fragment) {
420 - if (!fragment) {
421 - return false;
422 - }
423 -
424 - return /^#[^\s#?\/]*$/.test(fragment);
425 -}
426 -//# sourceMappingURL=is-valid-fragment.js.map
427 -;// CONCATENATED MODULE: ./packages/url/build-module/get-query-args.js
428 -/**
429 - * Internal dependencies
430 - */
431 -
432 -/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */
433 -
434 -/**
435 - * @typedef {Record<string,QueryArgParsed>} QueryArgs
436 - */
437 -
438 -/**
439 - * Sets a value in object deeply by a given array of path segments. Mutates the
440 - * object reference.
441 - *
442 - * @param {Record<string,*>} object Object in which to assign.
443 - * @param {string[]} path Path segment at which to set value.
444 - * @param {*} value Value to set.
445 - */
446 -
447 -function setPath(object, path, value) {
448 - const length = path.length;
449 - const lastIndex = length - 1;
450 -
451 - for (let i = 0; i < length; i++) {
452 - let key = path[i];
453 -
454 - if (!key && Array.isArray(object)) {
455 - // If key is empty string and next value is array, derive key from
456 - // the current length of the array.
457 - key = object.length.toString();
458 - } // If the next key in the path is numeric (or empty string), it will be
459 - // created as an array. Otherwise, it will be created as an object.
460 -
461 -
462 - const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
463 - object[key] = i === lastIndex ? // If at end of path, assign the intended value.
464 - value : // Otherwise, advance to the next object in the path, creating
465 - // it if it does not yet exist.
466 - object[key] || (isNextKeyArrayIndex ? [] : {});
467 -
468 - if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
469 - // If we current key is non-numeric, but the next value is an
470 - // array, coerce the value to an object.
471 - object[key] = { ...object[key]
472 - };
473 - } // Update working reference object to the next in the path.
474 -
475 -
476 - object = object[key];
477 - }
478 -}
479 -/**
480 - * Returns an object of query arguments of the given URL. If the given URL is
481 - * invalid or has no querystring, an empty object is returned.
482 - *
483 - * @param {string} url URL.
484 - *
485 - * @example
486 - * ```js
487 - * const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );
488 - * // { "foo": "bar", "bar": "baz" }
489 - * ```
490 - *
491 - * @return {QueryArgs} Query args object.
492 - */
493 -
494 -
495 -function getQueryArgs(url) {
496 - return (getQueryString(url) || '' // Normalize space encoding, accounting for PHP URL encoding
497 - // corresponding to `application/x-www-form-urlencoded`.
498 - //
499 - // See: https://tools.ietf.org/html/rfc1866#section-8.2.1
500 - ).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => {
501 - const [key, value = ''] = keyValue.split('=') // Filtering avoids decoding as `undefined` for value, where
502 - // default is restored in destructuring assignment.
503 - .filter(Boolean).map(decodeURIComponent);
504 -
505 - if (key) {
506 - const segments = key.replace(/\]/g, '').split('[');
507 - setPath(accumulator, segments, value);
508 - }
509 -
510 - return accumulator;
511 - }, {});
512 -}
513 -//# sourceMappingURL=get-query-args.js.map
514 -;// CONCATENATED MODULE: ./packages/url/build-module/add-query-args.js
515 -/**
516 - * Internal dependencies
517 - */
518 -
519 -
520 -/**
521 - * Appends arguments as querystring to the provided URL. If the URL already
522 - * includes query arguments, the arguments are merged with (and take precedent
523 - * over) the existing set.
524 - *
525 - * @param {string} [url=''] URL to which arguments should be appended. If omitted,
526 - * only the resulting querystring is returned.
527 - * @param {Object} [args] Query arguments to apply to URL.
528 - *
529 - * @example
530 - * ```js
531 - * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
532 - * ```
533 - *
534 - * @return {string} URL with arguments applied.
535 - */
536 -
537 -function addQueryArgs() {
538 - let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
539 - let args = arguments.length > 1 ? arguments[1] : undefined;
540 -
541 - // If no arguments are to be appended, return original URL.
542 - if (!args || !Object.keys(args).length) {
543 - return url;
544 - }
545 -
546 - let baseUrl = url; // Determine whether URL already had query arguments.
547 -
548 - const queryStringIndex = url.indexOf('?');
549 -
550 - if (queryStringIndex !== -1) {
551 - // Merge into existing query arguments.
552 - args = Object.assign(getQueryArgs(url), args); // Change working base URL to omit previous query arguments.
553 -
554 - baseUrl = baseUrl.substr(0, queryStringIndex);
555 - }
556 -
557 - return baseUrl + '?' + buildQueryString(args);
558 -}
559 -//# sourceMappingURL=add-query-args.js.map
560 -;// CONCATENATED MODULE: ./packages/url/build-module/get-query-arg.js
561 -/**
562 - * Internal dependencies
563 - */
564 -
565 -/**
566 - * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
567 - */
568 -
569 -/**
570 - * @typedef {string|string[]|QueryArgObject} QueryArgParsed
571 - */
572 -
573 -/**
574 - * Returns a single query argument of the url
575 - *
576 - * @param {string} url URL.
577 - * @param {string} arg Query arg name.
578 - *
579 - * @example
580 - * ```js
581 - * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar
582 - * ```
583 - *
584 - * @return {QueryArgParsed|void} Query arg value.
585 - */
586 -
587 -function getQueryArg(url, arg) {
588 - return getQueryArgs(url)[arg];
589 -}
590 -//# sourceMappingURL=get-query-arg.js.map
591 -;// CONCATENATED MODULE: ./packages/url/build-module/has-query-arg.js
592 -/**
593 - * Internal dependencies
594 - */
595 -
596 -/**
597 - * Determines whether the URL contains a given query arg.
598 - *
599 - * @param {string} url URL.
600 - * @param {string} arg Query arg name.
601 - *
602 - * @example
603 - * ```js
604 - * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
605 - * ```
606 - *
607 - * @return {boolean} Whether or not the URL contains the query arg.
608 - */
609 -
610 -function hasQueryArg(url, arg) {
611 - return getQueryArg(url, arg) !== undefined;
612 -}
613 -//# sourceMappingURL=has-query-arg.js.map
614 -;// CONCATENATED MODULE: ./packages/url/build-module/remove-query-args.js
615 -/**
616 - * Internal dependencies
617 - */
618 -
619 -
620 -/**
621 - * Removes arguments from the query string of the url
622 - *
623 - * @param {string} url URL.
624 - * @param {...string} args Query Args.
625 - *
626 - * @example
627 - * ```js
628 - * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
629 - * ```
630 - *
631 - * @return {string} Updated URL.
632 - */
633 -
634 -function removeQueryArgs(url) {
635 - const queryStringIndex = url.indexOf('?');
636 -
637 - if (queryStringIndex === -1) {
638 - return url;
639 - }
640 -
641 - const query = getQueryArgs(url);
642 - const baseURL = url.substr(0, queryStringIndex);
643 -
644 - for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
645 - args[_key - 1] = arguments[_key];
646 - }
647 -
648 - args.forEach(arg => delete query[arg]);
649 - const queryString = buildQueryString(query);
650 - return queryString ? baseURL + '?' + queryString : baseURL;
651 -}
652 -//# sourceMappingURL=remove-query-args.js.map
653 -;// CONCATENATED MODULE: ./packages/url/build-module/prepend-http.js
654 -/**
655 - * Internal dependencies
656 - */
657 -
658 -const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
659 -/**
660 - * Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
661 - *
662 - * @param {string} url The URL to test.
663 - *
664 - * @example
665 - * ```js
666 - * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org
667 - * ```
668 - *
669 - * @return {string} The updated URL.
670 - */
671 -
672 -function prependHTTP(url) {
673 - if (!url) {
674 - return url;
675 - }
676 -
677 - url = url.trim();
678 -
679 - if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
680 - return 'http://' + url;
681 - }
682 -
683 - return url;
684 -}
685 -//# sourceMappingURL=prepend-http.js.map
686 -;// CONCATENATED MODULE: ./packages/url/build-module/safe-decode-uri.js
687 -/**
688 - * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
689 - * `decodeURI` throws an error.
690 - *
691 - * @param {string} uri URI to decode.
692 - *
693 - * @example
694 - * ```js
695 - * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
696 - * ```
697 - *
698 - * @return {string} Decoded URI if possible.
699 - */
700 -function safeDecodeURI(uri) {
701 - try {
702 - return decodeURI(uri);
703 - } catch (uriError) {
704 - return uri;
705 - }
706 -}
707 -//# sourceMappingURL=safe-decode-uri.js.map
708 -;// CONCATENATED MODULE: ./packages/url/build-module/safe-decode-uri-component.js
709 -/**
710 - * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
711 - * `decodeURIComponent` throws an error.
712 - *
713 - * @param {string} uriComponent URI component to decode.
714 - *
715 - * @return {string} Decoded URI component if possible.
716 - */
717 -function safeDecodeURIComponent(uriComponent) {
718 - try {
719 - return decodeURIComponent(uriComponent);
720 - } catch (uriComponentError) {
721 - return uriComponent;
722 - }
723 -}
724 -//# sourceMappingURL=safe-decode-uri-component.js.map
725 -;// CONCATENATED MODULE: ./packages/url/build-module/filter-url-for-display.js
726 -/**
727 - * Returns a URL for display.
728 - *
729 - * @param {string} url Original URL.
730 - * @param {number|null} maxLength URL length.
731 - *
732 - * @example
733 - * ```js
734 - * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
735 - * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
736 - * ```
737 - *
738 - * @return {string} Displayed URL.
739 - */
740 -function filterURLForDisplay(url) {
741 - let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
742 - // Remove protocol and www prefixes.
743 - let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
744 -
745 - if (filteredURL.match(/^[^\/]+\/$/)) {
746 - filteredURL = filteredURL.replace('/', '');
747 - }
748 -
749 - const mediaRegexp = /([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/;
750 -
751 - if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(mediaRegexp)) {
752 - return filteredURL;
753 - } // If the file is not greater than max length, return last portion of URL.
754 -
755 -
756 - filteredURL = filteredURL.split('?')[0];
757 - const urlPieces = filteredURL.split('/');
758 - const file = urlPieces[urlPieces.length - 1];
759 -
760 - if (file.length <= maxLength) {
761 - return '…' + filteredURL.slice(-maxLength);
762 - } // If the file is greater than max length, truncate the file.
763 -
764 -
765 - const index = file.lastIndexOf('.');
766 - const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)];
767 - const truncatedFile = fileName.slice(-3) + '.' + extension;
768 - return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile;
769 -}
770 -//# sourceMappingURL=filter-url-for-display.js.map
771 -;// CONCATENATED MODULE: external "lodash"
772 -var external_lodash_namespaceObject = window["lodash"];
773 -;// CONCATENATED MODULE: ./packages/url/build-module/clean-for-slug.js
774 -/**
775 - * External dependencies
776 - */
777 -
778 -/**
779 - * Performs some basic cleanup of a string for use as a post slug.
780 - *
781 - * This replicates some of what `sanitize_title()` does in WordPress core, but
782 - * is only designed to approximate what the slug will be.
783 - *
784 - * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin
785 - * letters. Removes combining diacritical marks. Converts whitespace, periods,
786 - * and forward slashes to hyphens. Removes any remaining non-word characters
787 - * except hyphens. Converts remaining string to lowercase. It does not account
788 - * for octets, HTML entities, or other encoded characters.
789 - *
790 - * @param {string} string Title or slug to be processed.
791 - *
792 - * @return {string} Processed string.
793 - */
794 -
795 -function cleanForSlug(string) {
796 - if (!string) {
797 - return '';
798 - }
799 -
800 - return (0,external_lodash_namespaceObject.trim)((0,external_lodash_namespaceObject.deburr)(string).replace(/[\s\./]+/g, '-').replace(/[^\w-]+/g, '').toLowerCase(), '-');
801 -}
802 -//# sourceMappingURL=clean-for-slug.js.map
803 -;// CONCATENATED MODULE: ./packages/url/build-module/get-filename.js
804 -/**
805 - * Returns the filename part of the URL.
806 - *
807 - * @param {string} url The full URL.
808 - *
809 - * @example
810 - * ```js
811 - * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'
812 - * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
813 - * ```
814 - *
815 - * @return {string|void} The filename part of the URL.
816 - */
817 -function getFilename(url) {
818 - let filename;
819 -
820 - try {
821 - filename = new URL(url, 'http://example.com').pathname.split('/').pop();
822 - } catch (error) {}
823 -
824 - if (filename) {
825 - return filename;
826 - }
827 -}
828 -//# sourceMappingURL=get-filename.js.map
829 -;// CONCATENATED MODULE: ./packages/url/build-module/normalize-path.js
830 -/**
831 - * Given a path, returns a normalized path where equal query parameter values
832 - * will be treated as identical, regardless of order they appear in the original
833 - * text.
834 - *
835 - * @param {string} path Original path.
836 - *
837 - * @return {string} Normalized path.
838 - */
839 -function normalizePath(path) {
840 - const splitted = path.split('?');
841 - const query = splitted[1];
842 - const base = splitted[0];
843 -
844 - if (!query) {
845 - return base;
846 - } // 'b=1&c=2&a=5'
847 -
848 -
849 - return base + '?' + query // [ 'b=1', 'c=2', 'a=5' ]
850 - .split('&') // [ [ 'b, '1' ], [ 'c', '2' ], [ 'a', '5' ] ]
851 - .map(entry => entry.split('=')) // [ [ 'a', '5' ], [ 'b, '1' ], [ 'c', '2' ] ]
852 - .sort((a, b) => a[0].localeCompare(b[0])) // [ 'a=5', 'b=1', 'c=2' ]
853 - .map(pair => pair.join('=')) // 'a=5&b=1&c=2'
854 - .join('&');
855 -}
856 -//# sourceMappingURL=normalize-path.js.map
857 -;// CONCATENATED MODULE: ./packages/url/build-module/index.js
858 -
859 -
860 -
861 -
862 -
863 -
864 -
865 -
866 -
867 -
868 -
869 -
870 -
871 -
872 -
873 -
874 -
875 -
876 -
877 -
878 -
879 -
880 -
881 -
882 -
883 -
884 -//# sourceMappingURL=index.js.map
885 -(window.wp = window.wp || {}).url = __webpack_exports__;
886 -/******/ })()
887 -;
1 +window.wp=window.wp||{},window.wp.url=function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=531)}({2:function(t,r){t.exports=window.lodash},24:function(t,r,n){"use strict";function e(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}n.d(r,"a",(function(){return e}))},30:function(t,r,n){"use strict";n.d(r,"a",(function(){return o}));var e=n(24);function o(t,r){if(t){if("string"==typeof t)return Object(e.a)(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Object(e.a)(t,r):void 0}}},39:function(t,r,n){"use strict";function e(t){if(Array.isArray(t))return t}n.d(r,"a",(function(){return e}))},40:function(t,r,n){"use strict";function e(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.d(r,"a",(function(){return e}))},5:function(t,r,n){"use strict";function e(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}n.d(r,"a",(function(){return e}))},531:function(t,r,n){"use strict";function e(t){try{return new URL(t),!0}catch(t){return!1}}n.r(r),n.d(r,"isURL",(function(){return e})),n.d(r,"isEmail",(function(){return u})),n.d(r,"getProtocol",(function(){return i})),n.d(r,"isValidProtocol",(function(){return c})),n.d(r,"getAuthority",(function(){return a})),n.d(r,"isValidAuthority",(function(){return f})),n.d(r,"getPath",(function(){return l})),n.d(r,"isValidPath",(function(){return s})),n.d(r,"getQueryString",(function(){return d})),n.d(r,"buildQueryString",(function(){return v})),n.d(r,"isValidQueryString",(function(){return g})),n.d(r,"getPathAndQueryString",(function(){return h})),n.d(r,"getFragment",(function(){return m})),n.d(r,"isValidFragment",(function(){return O})),n.d(r,"addQueryArgs",(function(){return P})),n.d(r,"getQueryArg",(function(){return x})),n.d(r,"getQueryArgs",(function(){return A})),n.d(r,"hasQueryArg",(function(){return I})),n.d(r,"removeQueryArgs",(function(){return U})),n.d(r,"prependHTTP",(function(){return R})),n.d(r,"safeDecodeURI",(function(){return Q})),n.d(r,"safeDecodeURIComponent",(function(){return C})),n.d(r,"filterURLForDisplay",(function(){return D})),n.d(r,"cleanForSlug",(function(){return z}));var o=/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;function u(t){return o.test(t)}function i(t){var r=/^([^\s:]+:)/.exec(t);if(r)return r[1]}function c(t){return!!t&&/^[a-z\-.\+]+[0-9]*:$/i.test(t)}function a(t){var r=/^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(t);if(r)return r[1]}function f(t){return!!t&&/^[^\s#?]+$/.test(t)}function l(t){var r=/^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(t);if(r)return r[1]}function s(t){return!!t&&/^[^\s#?]+$/.test(t)}function d(t){var r;try{r=new URL(t,"http://example.com").search.substring(1)}catch(t){}if(r)return r}var y=n(8);function p(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return b(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0,o=function(){};return{s:o,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,i=!0,c=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return i=t.done,t},e:function(t){c=!0,u=t},f:function(){try{i||null==n.return||n.return()}finally{if(c)throw u}}}}function b(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function v(t){for(var r,n="",e=Object.entries(t);r=e.shift();){var o=r,u=Object(y.a)(o,2),i=u[0],c=u[1];if(Array.isArray(c)||c&&c.constructor===Object){var a,f=p(Object.entries(c).reverse());try{for(f.s();!(a=f.n()).done;){var l=Object(y.a)(a.value,2),s=l[0],d=l[1];e.unshift(["".concat(i,"[").concat(s,"]"),d])}}catch(t){f.e(t)}finally{f.f()}}else void 0!==c&&(null===c&&(c=""),n+="&"+[i,c].map(encodeURIComponent).join("="))}return n.substr(1)}function g(t){return!!t&&/^[^\s#?\/]+$/.test(t)}function h(t){var r=l(t),n=d(t),e="/";return r&&(e+=r),n&&(e+="?".concat(n)),e}function m(t){var r=/^\S+?(#[^\s\?]*)/.exec(t);if(r)return r[1]}function O(t){return!!t&&/^#[^\s#?\/]*$/.test(t)}var j=n(5);function w(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),n.push.apply(n,e)}return n}function S(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?w(Object(n),!0).forEach((function(r){Object(j.a)(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))}))}return t}function A(t){return(d(t)||"").replace(/\+/g,"%20").split("&").reduce((function(t,r){var n=r.split("=").filter(Boolean).map(decodeURIComponent),e=Object(y.a)(n,2),o=e[0],u=e[1],i=void 0===u?"":u;return o&&function(t,r,n){for(var e=r.length,o=e-1,u=0;u<e;u++){var i=r[u];!i&&Array.isArray(t)&&(i=t.length.toString());var c=!isNaN(Number(r[u+1]));t[i]=u===o?n:t[i]||(c?[]:{}),Array.isArray(t[i])&&!c&&(t[i]=S({},t[i])),t=t[i]}}(t,o.replace(/\]/g,"").split("["),i),t}),{})}function P(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;if(!r||!Object.keys(r).length)return t;var n=t,e=t.indexOf("?");return-1!==e&&(r=Object.assign(A(t),r),n=n.substr(0,e)),n+"?"+v(r)}function x(t,r){return A(t)[r]}function I(t,r){return void 0!==x(t,r)}function U(t){var r=t.indexOf("?");if(-1===r)return t;for(var n=A(t),e=t.substr(0,r),o=arguments.length,u=new Array(o>1?o-1:0),i=1;i<o;i++)u[i-1]=arguments[i];u.forEach((function(t){return delete n[t]}));var c=v(n);return c?e+"?"+c:e}var $=/^(?:[a-z]+:|#|\?|\.|\/)/i;function R(t){return t?(t=t.trim(),$.test(t)||u(t)?t:"http://"+t):t}function Q(t){try{return decodeURI(t)}catch(r){return t}}function C(t){try{return decodeURIComponent(t)}catch(r){return t}}function D(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=t.replace(/^(?:https?:)\/\/(?:www\.)?/,"");n.match(/^[^\/]+\/$/)&&(n=n.replace("/",""));var e=/([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/;if(!r||n.length<=r||!n.match(e))return n;var o=(n=n.split("?")[0]).split("/"),u=o[o.length-1];if(u.length<=r)return"…"+n.slice(-r);var i=u.lastIndexOf("."),c=[u.slice(0,i),u.slice(i+1)],a=c[0],f=c[1],l=a.slice(-3)+"."+f;return u.slice(0,r-l.length-1)+"…"+l}var _=n(2);function z(t){return t?Object(_.trim)(Object(_.deburr)(t).replace(/[\s\./]+/g,"-").replace(/[^\w-]+/g,"").toLowerCase(),"-"):""}},8:function(t,r,n){"use strict";n.d(r,"a",(function(){return i}));var e=n(39),o=n(30),u=n(40);function i(t,r){return Object(e.a)(t)||function(t,r){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],_n=!0,e=!1,o=void 0;try{for(var u,i=t[Symbol.iterator]();!(_n=(u=i.next()).done)&&(n.push(u.value),!r||n.length!==r);_n=!0);}catch(t){e=!0,o=t}finally{try{_n||null==i.return||i.return()}finally{if(e)throw o}}return n}}(t,r)||Object(o.a)(t,r)||Object(u.a)()}}});