@wordpress/url 4.32.0 → 4.32.1-next.47f435fc9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/build/add-query-args.js +35 -40
  2. package/build/add-query-args.js.map +7 -1
  3. package/build/build-query-string.js +30 -43
  4. package/build/build-query-string.js.map +7 -1
  5. package/build/clean-for-slug.js +39 -43
  6. package/build/clean-for-slug.js.map +7 -1
  7. package/build/filter-url-for-display.js +39 -39
  8. package/build/filter-url-for-display.js.map +7 -1
  9. package/build/get-authority.js +29 -19
  10. package/build/get-authority.js.map +7 -1
  11. package/build/get-filename.js +29 -21
  12. package/build/get-filename.js.map +7 -1
  13. package/build/get-fragment.js +26 -18
  14. package/build/get-fragment.js.map +7 -1
  15. package/build/get-path-and-query-string.js +30 -26
  16. package/build/get-path-and-query-string.js.map +7 -1
  17. package/build/get-path.js +26 -18
  18. package/build/get-path.js.map +7 -1
  19. package/build/get-protocol.js +26 -18
  20. package/build/get-protocol.js.map +7 -1
  21. package/build/get-query-arg.js +28 -24
  22. package/build/get-query-arg.js.map +7 -1
  23. package/build/get-query-args.js +42 -65
  24. package/build/get-query-args.js.map +7 -1
  25. package/build/get-query-string.js +29 -20
  26. package/build/get-query-string.js.map +7 -1
  27. package/build/has-query-arg.js +28 -24
  28. package/build/has-query-arg.js.map +7 -1
  29. package/build/index.js +109 -201
  30. package/build/index.js.map +7 -1
  31. package/build/is-email.js +26 -18
  32. package/build/is-email.js.map +7 -1
  33. package/build/is-phone-number.js +27 -20
  34. package/build/is-phone-number.js.map +7 -1
  35. package/build/is-url.js +26 -23
  36. package/build/is-url.js.map +7 -1
  37. package/build/is-valid-authority.js +26 -18
  38. package/build/is-valid-authority.js.map +7 -1
  39. package/build/is-valid-fragment.js +26 -18
  40. package/build/is-valid-fragment.js.map +7 -1
  41. package/build/is-valid-path.js +26 -18
  42. package/build/is-valid-path.js.map +7 -1
  43. package/build/is-valid-protocol.js +26 -18
  44. package/build/is-valid-protocol.js.map +7 -1
  45. package/build/is-valid-query-string.js +26 -18
  46. package/build/is-valid-query-string.js.map +7 -1
  47. package/build/normalize-path.js +28 -32
  48. package/build/normalize-path.js.map +7 -1
  49. package/build/prepend-http.js +29 -25
  50. package/build/prepend-http.js.map +7 -1
  51. package/build/prepend-https.js +30 -29
  52. package/build/prepend-https.js.map +7 -1
  53. package/build/remove-query-args.js +35 -31
  54. package/build/remove-query-args.js.map +7 -1
  55. package/build/safe-decode-uri-component.js +26 -13
  56. package/build/safe-decode-uri-component.js.map +7 -1
  57. package/build/safe-decode-uri.js +26 -18
  58. package/build/safe-decode-uri.js.map +7 -1
  59. package/build-module/add-query-args.js +12 -35
  60. package/build-module/add-query-args.js.map +7 -1
  61. package/build-module/build-query-string.js +9 -40
  62. package/build-module/build-query-string.js.map +7 -1
  63. package/build-module/clean-for-slug.js +8 -39
  64. package/build-module/clean-for-slug.js.map +7 -1
  65. package/build-module/filter-url-for-display.js +18 -36
  66. package/build-module/filter-url-for-display.js.map +7 -1
  67. package/build-module/get-authority.js +8 -16
  68. package/build-module/get-authority.js.map +7 -1
  69. package/build-module/get-filename.js +8 -18
  70. package/build-module/get-filename.js.map +7 -1
  71. package/build-module/get-fragment.js +5 -15
  72. package/build-module/get-fragment.js.map +7 -1
  73. package/build-module/get-path-and-query-string.js +7 -21
  74. package/build-module/get-path-and-query-string.js.map +7 -1
  75. package/build-module/get-path.js +5 -15
  76. package/build-module/get-path.js.map +7 -1
  77. package/build-module/get-protocol.js +5 -15
  78. package/build-module/get-protocol.js.map +7 -1
  79. package/build-module/get-query-arg.js +6 -19
  80. package/build-module/get-query-arg.js.map +7 -1
  81. package/build-module/get-query-args.js +21 -61
  82. package/build-module/get-query-args.js.map +7 -1
  83. package/build-module/get-query-string.js +8 -17
  84. package/build-module/get-query-string.js.map +7 -1
  85. package/build-module/has-query-arg.js +7 -21
  86. package/build-module/has-query-arg.js.map +7 -1
  87. package/build-module/index.js +59 -29
  88. package/build-module/index.js.map +7 -1
  89. package/build-module/is-email.js +5 -15
  90. package/build-module/is-email.js.map +7 -1
  91. package/build-module/is-phone-number.js +6 -17
  92. package/build-module/is-phone-number.js.map +7 -1
  93. package/build-module/is-url.js +5 -20
  94. package/build-module/is-url.js.map +7 -1
  95. package/build-module/is-valid-authority.js +5 -15
  96. package/build-module/is-valid-authority.js.map +7 -1
  97. package/build-module/is-valid-fragment.js +5 -15
  98. package/build-module/is-valid-fragment.js.map +7 -1
  99. package/build-module/is-valid-path.js +5 -15
  100. package/build-module/is-valid-path.js.map +7 -1
  101. package/build-module/is-valid-protocol.js +5 -15
  102. package/build-module/is-valid-protocol.js.map +7 -1
  103. package/build-module/is-valid-query-string.js +5 -15
  104. package/build-module/is-valid-query-string.js.map +7 -1
  105. package/build-module/normalize-path.js +7 -29
  106. package/build-module/normalize-path.js.map +7 -1
  107. package/build-module/prepend-http.js +7 -20
  108. package/build-module/prepend-http.js.map +7 -1
  109. package/build-module/prepend-https.js +8 -25
  110. package/build-module/prepend-https.js.map +7 -1
  111. package/build-module/remove-query-args.js +12 -26
  112. package/build-module/remove-query-args.js.map +7 -1
  113. package/build-module/safe-decode-uri-component.js +5 -10
  114. package/build-module/safe-decode-uri-component.js.map +7 -1
  115. package/build-module/safe-decode-uri.js +5 -15
  116. package/build-module/safe-decode-uri.js.map +7 -1
  117. package/package.json +10 -3
@@ -1,49 +1,44 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var add_query_args_exports = {};
20
+ __export(add_query_args_exports, {
21
+ addQueryArgs: () => addQueryArgs
5
22
  });
6
- exports.addQueryArgs = addQueryArgs;
7
- var _getQueryArgs = require("./get-query-args");
8
- var _buildQueryString = require("./build-query-string");
9
- var _getFragment = require("./get-fragment");
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- /**
15
- * Appends arguments as querystring to the provided URL. If the URL already
16
- * includes query arguments, the arguments are merged with (and take precedent
17
- * over) the existing set.
18
- *
19
- * @param url URL to which arguments should be appended. If omitted,
20
- * only the resulting querystring is returned.
21
- * @param args Query arguments to apply to URL.
22
- *
23
- * @example
24
- * ```js
25
- * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
26
- * ```
27
- *
28
- * @return URL with arguments applied.
29
- */
30
- function addQueryArgs(url = '', args) {
31
- // If no arguments are to be appended, return original URL.
23
+ module.exports = __toCommonJS(add_query_args_exports);
24
+ var import_get_query_args = require("./get-query-args");
25
+ var import_build_query_string = require("./build-query-string");
26
+ var import_get_fragment = require("./get-fragment");
27
+ function addQueryArgs(url = "", args) {
32
28
  if (!args || !Object.keys(args).length) {
33
29
  return url;
34
30
  }
35
- const fragment = (0, _getFragment.getFragment)(url) || '';
36
- let baseUrl = url.replace(fragment, '');
37
-
38
- // Determine whether URL already had query arguments.
39
- const queryStringIndex = url.indexOf('?');
31
+ const fragment = (0, import_get_fragment.getFragment)(url) || "";
32
+ let baseUrl = url.replace(fragment, "");
33
+ const queryStringIndex = url.indexOf("?");
40
34
  if (queryStringIndex !== -1) {
41
- // Merge into existing query arguments.
42
- args = Object.assign((0, _getQueryArgs.getQueryArgs)(url), args);
43
-
44
- // Change working base URL to omit previous query arguments.
35
+ args = Object.assign((0, import_get_query_args.getQueryArgs)(url), args);
45
36
  baseUrl = baseUrl.substr(0, queryStringIndex);
46
37
  }
47
- return baseUrl + '?' + (0, _buildQueryString.buildQueryString)(args) + fragment;
38
+ return baseUrl + "?" + (0, import_build_query_string.buildQueryString)(args) + fragment;
48
39
  }
49
- //# sourceMappingURL=add-query-args.js.map
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ addQueryArgs
43
+ });
44
+ //# sourceMappingURL=add-query-args.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_getQueryArgs","require","_buildQueryString","_getFragment","addQueryArgs","url","args","Object","keys","length","fragment","getFragment","baseUrl","replace","queryStringIndex","indexOf","assign","getQueryArgs","substr","buildQueryString"],"sources":["@wordpress/url/src/add-query-args.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\nimport { getFragment } from './get-fragment';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param url URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param args Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return URL with arguments applied.\n */\nexport function addQueryArgs(\n\turl: string = '',\n\targs?: Record< string, unknown >\n): string {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tconst fragment = getFragment( url ) || '';\n\tlet baseUrl = url.replace( fragment, '' );\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args ) + fragment;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,YAAYA,CAC3BC,GAAW,GAAG,EAAE,EAChBC,IAAgC,EACvB;EACT;EACA,IAAK,CAAEA,IAAI,IAAI,CAAEC,MAAM,CAACC,IAAI,CAAEF,IAAK,CAAC,CAACG,MAAM,EAAG;IAC7C,OAAOJ,GAAG;EACX;EAEA,MAAMK,QAAQ,GAAG,IAAAC,wBAAW,EAAEN,GAAI,CAAC,IAAI,EAAE;EACzC,IAAIO,OAAO,GAAGP,GAAG,CAACQ,OAAO,CAAEH,QAAQ,EAAE,EAAG,CAAC;;EAEzC;EACA,MAAMI,gBAAgB,GAAGT,GAAG,CAACU,OAAO,CAAE,GAAI,CAAC;EAC3C,IAAKD,gBAAgB,KAAK,CAAC,CAAC,EAAG;IAC9B;IACAR,IAAI,GAAGC,MAAM,CAACS,MAAM,CAAE,IAAAC,0BAAY,EAAEZ,GAAI,CAAC,EAAEC,IAAK,CAAC;;IAEjD;IACAM,OAAO,GAAGA,OAAO,CAACM,MAAM,CAAE,CAAC,EAAEJ,gBAAiB,CAAC;EAChD;EAEA,OAAOF,OAAO,GAAG,GAAG,GAAG,IAAAO,kCAAgB,EAAEb,IAAK,CAAC,GAAGI,QAAQ;AAC3D","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/add-query-args.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\nimport { getFragment } from './get-fragment';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param url URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param args Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return URL with arguments applied.\n */\nexport function addQueryArgs(\n\turl: string = '',\n\targs?: Record< string, unknown >\n): string {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tconst fragment = getFragment( url ) || '';\n\tlet baseUrl = url.replace( fragment, '' );\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args ) + fragment;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA6B;AAC7B,gCAAiC;AACjC,0BAA4B;AAkBrB,SAAS,aACf,MAAc,IACd,MACS;AAET,MAAK,CAAE,QAAQ,CAAE,OAAO,KAAM,IAAK,EAAE,QAAS;AAC7C,WAAO;AAAA,EACR;AAEA,QAAM,eAAW,iCAAa,GAAI,KAAK;AACvC,MAAI,UAAU,IAAI,QAAS,UAAU,EAAG;AAGxC,QAAM,mBAAmB,IAAI,QAAS,GAAI;AAC1C,MAAK,qBAAqB,IAAK;AAE9B,WAAO,OAAO,WAAQ,oCAAc,GAAI,GAAG,IAAK;AAGhD,cAAU,QAAQ,OAAQ,GAAG,gBAAiB;AAAA,EAC/C;AAEA,SAAO,UAAU,UAAM,4CAAkB,IAAK,IAAI;AACnD;",
6
+ "names": []
7
+ }
@@ -1,62 +1,49 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var build_query_string_exports = {};
20
+ __export(build_query_string_exports, {
21
+ buildQueryString: () => buildQueryString
5
22
  });
6
- exports.buildQueryString = buildQueryString;
7
- /**
8
- * Generates URL-encoded query string using input query data.
9
- *
10
- * It is intended to behave equivalent as PHP's `http_build_query`, configured
11
- * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).
12
- *
13
- * @example
14
- * ```js
15
- * const queryString = buildQueryString( {
16
- * simple: 'is ok',
17
- * arrays: [ 'are', 'fine', 'too' ],
18
- * objects: {
19
- * evenNested: {
20
- * ok: 'yes',
21
- * },
22
- * },
23
- * } );
24
- * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
25
- * ```
26
- *
27
- * @param data Data to encode.
28
- *
29
- * @return Query string.
30
- */
23
+ module.exports = __toCommonJS(build_query_string_exports);
31
24
  function buildQueryString(data) {
32
- let string = '';
25
+ let string = "";
33
26
  const stack = Object.entries(data);
34
27
  let pair;
35
28
  while (pair = stack.shift()) {
36
29
  let [key, value] = pair;
37
-
38
- // Support building deeply nested data, from array or object values.
39
30
  const hasNestedData = Array.isArray(value) || value && value.constructor === Object;
40
31
  if (hasNestedData) {
41
- // Push array or object values onto the stack as composed of their
42
- // original key and nested index or key, retaining order by a
43
- // combination of Array#reverse and Array#unshift onto the stack.
44
32
  const valuePairs = Object.entries(value).reverse();
45
33
  for (const [member, memberValue] of valuePairs) {
46
34
  stack.unshift([`${key}[${member}]`, memberValue]);
47
35
  }
48
- } else if (value !== undefined) {
49
- // Null is treated as special case, equivalent to empty string.
36
+ } else if (value !== void 0) {
50
37
  if (value === null) {
51
- value = '';
38
+ value = "";
52
39
  }
53
- string += '&' + [key, String(value)].map(encodeURIComponent).join('=');
40
+ string += "&" + [key, String(value)].map(encodeURIComponent).join("=");
54
41
  }
55
42
  }
56
-
57
- // Loop will concatenate with leading `&`, but it's only expected for all
58
- // but the first query parameter. This strips the leading `&`, while still
59
- // accounting for the case that the string may in-fact be empty.
60
43
  return string.substr(1);
61
44
  }
62
- //# sourceMappingURL=build-query-string.js.map
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ buildQueryString
48
+ });
49
+ //# sourceMappingURL=build-query-string.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["buildQueryString","data","string","stack","Object","entries","pair","shift","key","value","hasNestedData","Array","isArray","constructor","valuePairs","reverse","member","memberValue","unshift","undefined","String","map","encodeURIComponent","join","substr"],"sources":["@wordpress/url/src/build-query-string.ts"],"sourcesContent":["/**\n * Generates URL-encoded query string using input query data.\n *\n * It is intended to behave equivalent as PHP's `http_build_query`, configured\n * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).\n *\n * @example\n * ```js\n * const queryString = buildQueryString( {\n * simple: 'is ok',\n * arrays: [ 'are', 'fine', 'too' ],\n * objects: {\n * evenNested: {\n * ok: 'yes',\n * },\n * },\n * } );\n * // \"simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes\"\n * ```\n *\n * @param data Data to encode.\n *\n * @return Query string.\n */\nexport function buildQueryString( data: Record< string, unknown > ): string {\n\tlet string = '';\n\n\tconst stack: Array< [ string, unknown ] > = Object.entries( data );\n\n\tlet pair;\n\twhile ( ( pair = stack.shift() ) ) {\n\t\tlet [ key, value ] = pair;\n\n\t\t// Support building deeply nested data, from array or object values.\n\t\tconst hasNestedData =\n\t\t\tArray.isArray( value ) || ( value && value.constructor === Object );\n\n\t\tif ( hasNestedData ) {\n\t\t\t// Push array or object values onto the stack as composed of their\n\t\t\t// original key and nested index or key, retaining order by a\n\t\t\t// combination of Array#reverse and Array#unshift onto the stack.\n\t\t\tconst valuePairs = Object.entries( value as object ).reverse();\n\t\t\tfor ( const [ member, memberValue ] of valuePairs ) {\n\t\t\t\tstack.unshift( [ `${ key }[${ member }]`, memberValue ] );\n\t\t\t}\n\t\t} else if ( value !== undefined ) {\n\t\t\t// Null is treated as special case, equivalent to empty string.\n\t\t\tif ( value === null ) {\n\t\t\t\tvalue = '';\n\t\t\t}\n\n\t\t\tstring +=\n\t\t\t\t'&' +\n\t\t\t\t[ key, String( value ) ].map( encodeURIComponent ).join( '=' );\n\t\t}\n\t}\n\n\t// Loop will concatenate with leading `&`, but it's only expected for all\n\t// but the first query parameter. This strips the leading `&`, while still\n\t// accounting for the case that the string may in-fact be empty.\n\treturn string.substr( 1 );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAAEC,IAA+B,EAAW;EAC3E,IAAIC,MAAM,GAAG,EAAE;EAEf,MAAMC,KAAmC,GAAGC,MAAM,CAACC,OAAO,CAAEJ,IAAK,CAAC;EAElE,IAAIK,IAAI;EACR,OAAUA,IAAI,GAAGH,KAAK,CAACI,KAAK,CAAC,CAAC,EAAK;IAClC,IAAI,CAAEC,GAAG,EAAEC,KAAK,CAAE,GAAGH,IAAI;;IAEzB;IACA,MAAMI,aAAa,GAClBC,KAAK,CAACC,OAAO,CAAEH,KAAM,CAAC,IAAMA,KAAK,IAAIA,KAAK,CAACI,WAAW,KAAKT,MAAQ;IAEpE,IAAKM,aAAa,EAAG;MACpB;MACA;MACA;MACA,MAAMI,UAAU,GAAGV,MAAM,CAACC,OAAO,CAAEI,KAAgB,CAAC,CAACM,OAAO,CAAC,CAAC;MAC9D,KAAM,MAAM,CAAEC,MAAM,EAAEC,WAAW,CAAE,IAAIH,UAAU,EAAG;QACnDX,KAAK,CAACe,OAAO,CAAE,CAAE,GAAIV,GAAG,IAAMQ,MAAM,GAAI,EAAEC,WAAW,CAAG,CAAC;MAC1D;IACD,CAAC,MAAM,IAAKR,KAAK,KAAKU,SAAS,EAAG;MACjC;MACA,IAAKV,KAAK,KAAK,IAAI,EAAG;QACrBA,KAAK,GAAG,EAAE;MACX;MAEAP,MAAM,IACL,GAAG,GACH,CAAEM,GAAG,EAAEY,MAAM,CAAEX,KAAM,CAAC,CAAE,CAACY,GAAG,CAAEC,kBAAmB,CAAC,CAACC,IAAI,CAAE,GAAI,CAAC;IAChE;EACD;;EAEA;EACA;EACA;EACA,OAAOrB,MAAM,CAACsB,MAAM,CAAE,CAAE,CAAC;AAC1B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/build-query-string.ts"],
4
+ "sourcesContent": ["/**\n * Generates URL-encoded query string using input query data.\n *\n * It is intended to behave equivalent as PHP's `http_build_query`, configured\n * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).\n *\n * @example\n * ```js\n * const queryString = buildQueryString( {\n * simple: 'is ok',\n * arrays: [ 'are', 'fine', 'too' ],\n * objects: {\n * evenNested: {\n * ok: 'yes',\n * },\n * },\n * } );\n * // \"simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes\"\n * ```\n *\n * @param data Data to encode.\n *\n * @return Query string.\n */\nexport function buildQueryString( data: Record< string, unknown > ): string {\n\tlet string = '';\n\n\tconst stack: Array< [ string, unknown ] > = Object.entries( data );\n\n\tlet pair;\n\twhile ( ( pair = stack.shift() ) ) {\n\t\tlet [ key, value ] = pair;\n\n\t\t// Support building deeply nested data, from array or object values.\n\t\tconst hasNestedData =\n\t\t\tArray.isArray( value ) || ( value && value.constructor === Object );\n\n\t\tif ( hasNestedData ) {\n\t\t\t// Push array or object values onto the stack as composed of their\n\t\t\t// original key and nested index or key, retaining order by a\n\t\t\t// combination of Array#reverse and Array#unshift onto the stack.\n\t\t\tconst valuePairs = Object.entries( value as object ).reverse();\n\t\t\tfor ( const [ member, memberValue ] of valuePairs ) {\n\t\t\t\tstack.unshift( [ `${ key }[${ member }]`, memberValue ] );\n\t\t\t}\n\t\t} else if ( value !== undefined ) {\n\t\t\t// Null is treated as special case, equivalent to empty string.\n\t\t\tif ( value === null ) {\n\t\t\t\tvalue = '';\n\t\t\t}\n\n\t\t\tstring +=\n\t\t\t\t'&' +\n\t\t\t\t[ key, String( value ) ].map( encodeURIComponent ).join( '=' );\n\t\t}\n\t}\n\n\t// Loop will concatenate with leading `&`, but it's only expected for all\n\t// but the first query parameter. This strips the leading `&`, while still\n\t// accounting for the case that the string may in-fact be empty.\n\treturn string.substr( 1 );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBO,SAAS,iBAAkB,MAA0C;AAC3E,MAAI,SAAS;AAEb,QAAM,QAAsC,OAAO,QAAS,IAAK;AAEjE,MAAI;AACJ,SAAU,OAAO,MAAM,MAAM,GAAM;AAClC,QAAI,CAAE,KAAK,KAAM,IAAI;AAGrB,UAAM,gBACL,MAAM,QAAS,KAAM,KAAO,SAAS,MAAM,gBAAgB;AAE5D,QAAK,eAAgB;AAIpB,YAAM,aAAa,OAAO,QAAS,KAAgB,EAAE,QAAQ;AAC7D,iBAAY,CAAE,QAAQ,WAAY,KAAK,YAAa;AACnD,cAAM,QAAS,CAAE,GAAI,GAAI,IAAK,MAAO,KAAK,WAAY,CAAE;AAAA,MACzD;AAAA,IACD,WAAY,UAAU,QAAY;AAEjC,UAAK,UAAU,MAAO;AACrB,gBAAQ;AAAA,MACT;AAEA,gBACC,MACA,CAAE,KAAK,OAAQ,KAAM,CAAE,EAAE,IAAK,kBAAmB,EAAE,KAAM,GAAI;AAAA,IAC/D;AAAA,EACD;AAKA,SAAO,OAAO,OAAQ,CAAE;AACzB;",
6
+ "names": []
7
+ }
@@ -1,49 +1,45 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var clean_for_slug_exports = {};
30
+ __export(clean_for_slug_exports, {
31
+ cleanForSlug: () => cleanForSlug
6
32
  });
7
- exports.cleanForSlug = cleanForSlug;
8
- var _removeAccents = _interopRequireDefault(require("remove-accents"));
9
- /**
10
- * External dependencies
11
- */
12
-
13
- /**
14
- * Performs some basic cleanup of a string for use as a post slug.
15
- *
16
- * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but
17
- * is only designed to approximate what the slug will be.
18
- *
19
- * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin
20
- * letters. Removes combining diacritical marks. Converts whitespace, periods,
21
- * and forward slashes to hyphens. Removes any remaining non-word characters
22
- * except hyphens. Converts remaining string to lowercase. It does not account
23
- * for octets, HTML entities, or other encoded characters.
24
- *
25
- * @param string Title or slug to be processed.
26
- *
27
- * @return Processed string.
28
- */
33
+ module.exports = __toCommonJS(clean_for_slug_exports);
34
+ var import_remove_accents = __toESM(require("remove-accents"));
29
35
  function cleanForSlug(string) {
30
36
  if (!string) {
31
- return '';
37
+ return "";
32
38
  }
33
- return (0, _removeAccents.default)(string)
34
- // Convert &nbsp, &ndash, and &mdash to hyphens.
35
- .replace(/(&nbsp;|&ndash;|&mdash;)/g, '-')
36
- // Convert each group of whitespace, periods, and forward slashes to a hyphen.
37
- .replace(/[\s\./]+/g, '-')
38
- // Remove all HTML entities.
39
- .replace(/&\S+?;/g, '')
40
- // Remove anything that's not a letter, number, underscore or hyphen.
41
- .replace(/[^\p{L}\p{N}_-]+/gu, '')
42
- // Convert to lowercase
43
- .toLowerCase()
44
- // Replace multiple hyphens with a single one.
45
- .replace(/-+/g, '-')
46
- // Remove any remaining leading or trailing hyphens.
47
- .replace(/(^-+)|(-+$)/g, '');
39
+ return (0, import_remove_accents.default)(string).replace(/(&nbsp;|&ndash;|&mdash;)/g, "-").replace(/[\s\./]+/g, "-").replace(/&\S+?;/g, "").replace(/[^\p{L}\p{N}_-]+/gu, "").toLowerCase().replace(/-+/g, "-").replace(/(^-+)|(-+$)/g, "");
48
40
  }
49
- //# sourceMappingURL=clean-for-slug.js.map
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ cleanForSlug
44
+ });
45
+ //# sourceMappingURL=clean-for-slug.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_removeAccents","_interopRequireDefault","require","cleanForSlug","string","removeAccents","replace","toLowerCase"],"sources":["@wordpress/url/src/clean-for-slug.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param string Title or slug to be processed.\n *\n * @return Processed string.\n */\nexport function cleanForSlug( string: string ): string {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert &nbsp, &ndash, and &mdash to hyphens.\n\t\t\t.replace( /(&nbsp;|&ndash;|&mdash;)/g, '-' )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove all HTML entities.\n\t\t\t.replace( /&\\S+?;/g, '' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAEC,MAAc,EAAW;EACtD,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EACA,OACC,IAAAC,sBAAa,EAAED,MAAO;EACrB;EAAA,CACCE,OAAO,CAAE,2BAA2B,EAAE,GAAI;EAC3C;EAAA,CACCA,OAAO,CAAE,WAAW,EAAE,GAAI;EAC3B;EAAA,CACCA,OAAO,CAAE,SAAS,EAAE,EAAG;EACxB;EAAA,CACCA,OAAO,CAAE,oBAAoB,EAAE,EAAG;EACnC;EAAA,CACCC,WAAW,CAAC;EACb;EAAA,CACCD,OAAO,CAAE,KAAK,EAAE,GAAI;EACrB;EAAA,CACCA,OAAO,CAAE,cAAc,EAAE,EAAG,CAAC;AAEjC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/clean-for-slug.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param string Title or slug to be processed.\n *\n * @return Processed string.\n */\nexport function cleanForSlug( string: string ): string {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert &nbsp, &ndash, and &mdash to hyphens.\n\t\t\t.replace( /(&nbsp;|&ndash;|&mdash;)/g, '-' )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove all HTML entities.\n\t\t\t.replace( /&\\S+?;/g, '' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA0B;AAkBnB,SAAS,aAAc,QAAyB;AACtD,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AACA,aACC,sBAAAA,SAAe,MAAO,EAEpB,QAAS,6BAA6B,GAAI,EAE1C,QAAS,aAAa,GAAI,EAE1B,QAAS,WAAW,EAAG,EAEvB,QAAS,sBAAsB,EAAG,EAElC,YAAY,EAEZ,QAAS,OAAO,GAAI,EAEpB,QAAS,gBAAgB,EAAG;AAEhC;",
6
+ "names": ["removeAccents"]
7
+ }
@@ -1,54 +1,54 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var filter_url_for_display_exports = {};
20
+ __export(filter_url_for_display_exports, {
21
+ filterURLForDisplay: () => filterURLForDisplay
5
22
  });
6
- exports.filterURLForDisplay = filterURLForDisplay;
7
- /**
8
- * Returns a URL for display.
9
- *
10
- * @param url Original URL.
11
- * @param maxLength URL length.
12
- *
13
- * @example
14
- * ```js
15
- * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
16
- * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
17
- * ```
18
- *
19
- * @return Displayed URL.
20
- */
23
+ module.exports = __toCommonJS(filter_url_for_display_exports);
21
24
  function filterURLForDisplay(url, maxLength = null) {
22
25
  if (!url) {
23
- return '';
26
+ return "";
24
27
  }
25
-
26
- // Remove protocol and www prefixes.
27
- let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, '').replace(/^www\./i, '');
28
-
29
- // Ends with / and only has that single slash, strip it.
28
+ let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, "").replace(/^www\./i, "");
30
29
  if (filteredURL.match(/^[^\/]+\/$/)) {
31
- filteredURL = filteredURL.replace('/', '');
30
+ filteredURL = filteredURL.replace("/", "");
32
31
  }
33
-
34
- // capture file name from URL
35
32
  const fileRegexp = /\/([^\/?]+)\.(?:[\w]+)(?=\?|$)/;
36
33
  if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(fileRegexp)) {
37
34
  return filteredURL;
38
35
  }
39
-
40
- // If the file is not greater than max length, return last portion of URL.
41
- filteredURL = filteredURL.split('?')[0];
42
- const urlPieces = filteredURL.split('/');
36
+ filteredURL = filteredURL.split("?")[0];
37
+ const urlPieces = filteredURL.split("/");
43
38
  const file = urlPieces[urlPieces.length - 1];
44
39
  if (file.length <= maxLength) {
45
- return '…' + filteredURL.slice(-maxLength);
40
+ return "\u2026" + filteredURL.slice(-maxLength);
46
41
  }
47
-
48
- // If the file is greater than max length, truncate the file.
49
- const index = file.lastIndexOf('.');
50
- const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)];
51
- const truncatedFile = fileName.slice(-3) + '.' + extension;
52
- return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile;
42
+ const index = file.lastIndexOf(".");
43
+ const [fileName, extension] = [
44
+ file.slice(0, index),
45
+ file.slice(index + 1)
46
+ ];
47
+ const truncatedFile = fileName.slice(-3) + "." + extension;
48
+ return file.slice(0, maxLength - truncatedFile.length - 1) + "\u2026" + truncatedFile;
53
49
  }
54
- //# sourceMappingURL=filter-url-for-display.js.map
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ filterURLForDisplay
53
+ });
54
+ //# sourceMappingURL=filter-url-for-display.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","fileRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"sources":["@wordpress/url/src/filter-url-for-display.ts"],"sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png\n * ```\n *\n * @return Displayed URL.\n */\nexport function filterURLForDisplay(\n\turl: string,\n\tmaxLength: number | null = null\n): string {\n\tif ( ! url ) {\n\t\treturn '';\n\t}\n\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\t// capture file name from URL\n\tconst fileRegexp = /\\/([^\\/?]+)\\.(?:[\\w]+)(?=\\?|$)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( fileRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '…' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'…' +\n\t\ttruncatedFile\n\t);\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAClCC,GAAW,EACXC,SAAwB,GAAG,IAAI,EACtB;EACT,IAAK,CAAED,GAAG,EAAG;IACZ,OAAO,EAAE;EACV;;EAEA;EACA,IAAIE,WAAW,GAAGF,GAAG,CACnBG,OAAO,CAAE,6BAA6B,EAAE,EAAG,CAAC,CAC5CA,OAAO,CAAE,SAAS,EAAE,EAAG,CAAC;;EAE1B;EACA,IAAKD,WAAW,CAACE,KAAK,CAAE,YAAa,CAAC,EAAG;IACxCF,WAAW,GAAGA,WAAW,CAACC,OAAO,CAAE,GAAG,EAAE,EAAG,CAAC;EAC7C;;EAEA;EACA,MAAME,UAAU,GAAG,gCAAgC;EAEnD,IACC,CAAEJ,SAAS,IACXC,WAAW,CAACI,MAAM,IAAIL,SAAS,IAC/B,CAAEC,WAAW,CAACE,KAAK,CAAEC,UAAW,CAAC,EAChC;IACD,OAAOH,WAAW;EACnB;;EAEA;EACAA,WAAW,GAAGA,WAAW,CAACK,KAAK,CAAE,GAAI,CAAC,CAAE,CAAC,CAAE;EAC3C,MAAMC,SAAS,GAAGN,WAAW,CAACK,KAAK,CAAE,GAAI,CAAC;EAC1C,MAAME,IAAI,GAAGD,SAAS,CAAEA,SAAS,CAACF,MAAM,GAAG,CAAC,CAAE;EAC9C,IAAKG,IAAI,CAACH,MAAM,IAAIL,SAAS,EAAG;IAC/B,OAAO,GAAG,GAAGC,WAAW,CAACQ,KAAK,CAAE,CAACT,SAAU,CAAC;EAC7C;;EAEA;EACA,MAAMU,KAAK,GAAGF,IAAI,CAACG,WAAW,CAAE,GAAI,CAAC;EACrC,MAAM,CAAEC,QAAQ,EAAEC,SAAS,CAAE,GAAG,CAC/BL,IAAI,CAACC,KAAK,CAAE,CAAC,EAAEC,KAAM,CAAC,EACtBF,IAAI,CAACC,KAAK,CAAEC,KAAK,GAAG,CAAE,CAAC,CACvB;EACD,MAAMI,aAAa,GAAGF,QAAQ,CAACH,KAAK,CAAE,CAAC,CAAE,CAAC,GAAG,GAAG,GAAGI,SAAS;EAC5D,OACCL,IAAI,CAACC,KAAK,CAAE,CAAC,EAAET,SAAS,GAAGc,aAAa,CAACT,MAAM,GAAG,CAAE,CAAC,GACrD,GAAG,GACHS,aAAa;AAEf","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/filter-url-for-display.ts"],
4
+ "sourcesContent": ["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // \u2026ent/uploads/img.png\n * ```\n *\n * @return Displayed URL.\n */\nexport function filterURLForDisplay(\n\turl: string,\n\tmaxLength: number | null = null\n): string {\n\tif ( ! url ) {\n\t\treturn '';\n\t}\n\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\t// capture file name from URL\n\tconst fileRegexp = /\\/([^\\/?]+)\\.(?:[\\w]+)(?=\\?|$)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( fileRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '\u2026' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'\u2026' +\n\t\ttruncatedFile\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,oBACf,KACA,YAA2B,MAClB;AACT,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAI,cAAc,IAChB,QAAS,+BAA+B,EAAG,EAC3C,QAAS,WAAW,EAAG;AAGzB,MAAK,YAAY,MAAO,YAAa,GAAI;AACxC,kBAAc,YAAY,QAAS,KAAK,EAAG;AAAA,EAC5C;AAGA,QAAM,aAAa;AAEnB,MACC,CAAE,aACF,YAAY,UAAU,aACtB,CAAE,YAAY,MAAO,UAAW,GAC/B;AACD,WAAO;AAAA,EACR;AAGA,gBAAc,YAAY,MAAO,GAAI,EAAG,CAAE;AAC1C,QAAM,YAAY,YAAY,MAAO,GAAI;AACzC,QAAM,OAAO,UAAW,UAAU,SAAS,CAAE;AAC7C,MAAK,KAAK,UAAU,WAAY;AAC/B,WAAO,WAAM,YAAY,MAAO,CAAC,SAAU;AAAA,EAC5C;AAGA,QAAM,QAAQ,KAAK,YAAa,GAAI;AACpC,QAAM,CAAE,UAAU,SAAU,IAAI;AAAA,IAC/B,KAAK,MAAO,GAAG,KAAM;AAAA,IACrB,KAAK,MAAO,QAAQ,CAAE;AAAA,EACvB;AACA,QAAM,gBAAgB,SAAS,MAAO,EAAG,IAAI,MAAM;AACnD,SACC,KAAK,MAAO,GAAG,YAAY,cAAc,SAAS,CAAE,IACpD,WACA;AAEF;",
6
+ "names": []
7
+ }
@@ -1,26 +1,36 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_authority_exports = {};
20
+ __export(get_authority_exports, {
21
+ getAuthority: () => getAuthority
5
22
  });
6
- exports.getAuthority = getAuthority;
7
- /**
8
- * Returns the authority part of the URL.
9
- *
10
- * @param url The full URL.
11
- *
12
- * @example
13
- * ```js
14
- * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'
15
- * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
16
- * ```
17
- *
18
- * @return The authority part of the URL.
19
- */
23
+ module.exports = __toCommonJS(get_authority_exports);
20
24
  function getAuthority(url) {
21
- const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
25
+ const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(
26
+ url
27
+ );
22
28
  if (matches) {
23
29
  return matches[1];
24
30
  }
25
31
  }
26
- //# sourceMappingURL=get-authority.js.map
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ getAuthority
35
+ });
36
+ //# sourceMappingURL=get-authority.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getAuthority","url","matches","exec"],"sources":["@wordpress/url/src/get-authority.ts"],"sourcesContent":["/**\n * Returns the authority part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'\n * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'\n * ```\n *\n * @return The authority part of the URL.\n */\nexport function getAuthority( url: string ): string | void {\n\tconst matches = /^[^\\/\\s:]+:(?:\\/\\/)?\\/?([^\\/\\s#?]+)[\\/#?]{0,1}\\S*$/.exec(\n\t\turl\n\t);\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAYA,CAAEC,GAAW,EAAkB;EAC1D,MAAMC,OAAO,GAAG,oDAAoD,CAACC,IAAI,CACxEF,GACD,CAAC;EACD,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/get-authority.ts"],
4
+ "sourcesContent": ["/**\n * Returns the authority part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'\n * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'\n * ```\n *\n * @return The authority part of the URL.\n */\nexport function getAuthority( url: string ): string | void {\n\tconst matches = /^[^\\/\\s:]+:(?:\\/\\/)?\\/?([^\\/\\s#?]+)[\\/#?]{0,1}\\S*$/.exec(\n\t\turl\n\t);\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,aAAc,KAA6B;AAC1D,QAAM,UAAU,qDAAqD;AAAA,IACpE;AAAA,EACD;AACA,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
6
+ "names": []
7
+ }
@@ -1,33 +1,41 @@
1
- /* wp:polyfill */
2
1
  "use strict";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_filename_exports = {};
20
+ __export(get_filename_exports, {
21
+ getFilename: () => getFilename
6
22
  });
7
- exports.getFilename = getFilename;
8
- /**
9
- * Returns the filename part of the URL.
10
- *
11
- * @param url The full URL.
12
- *
13
- * @example
14
- * ```js
15
- * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'
16
- * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
17
- * ```
18
- *
19
- * @return The filename part of the URL.
20
- */
23
+ module.exports = __toCommonJS(get_filename_exports);
21
24
  function getFilename(url) {
22
25
  let filename;
23
26
  if (!url) {
24
27
  return;
25
28
  }
26
29
  try {
27
- filename = new URL(url, 'http://example.com').pathname.split('/').pop();
28
- } catch (error) {}
30
+ filename = new URL(url, "http://example.com").pathname.split("/").pop();
31
+ } catch (error) {
32
+ }
29
33
  if (filename) {
30
34
  return filename;
31
35
  }
32
36
  }
33
- //# sourceMappingURL=get-filename.js.map
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ getFilename
40
+ });
41
+ //# sourceMappingURL=get-filename.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getFilename","url","filename","URL","pathname","split","pop","error"],"sources":["@wordpress/url/src/get-filename.ts"],"sourcesContent":["/**\n * Returns the filename part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'\n * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'\n * ```\n *\n * @return The filename part of the URL.\n */\nexport function getFilename( url: string ): string | void {\n\tlet filename;\n\n\tif ( ! url ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tfilename = new URL( url, 'http://example.com' ).pathname\n\t\t\t.split( '/' )\n\t\t\t.pop();\n\t} catch ( error ) {}\n\n\tif ( filename ) {\n\t\treturn filename;\n\t}\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAWA,CAAEC,GAAW,EAAkB;EACzD,IAAIC,QAAQ;EAEZ,IAAK,CAAED,GAAG,EAAG;IACZ;EACD;EAEA,IAAI;IACHC,QAAQ,GAAG,IAAIC,GAAG,CAAEF,GAAG,EAAE,oBAAqB,CAAC,CAACG,QAAQ,CACtDC,KAAK,CAAE,GAAI,CAAC,CACZC,GAAG,CAAC,CAAC;EACR,CAAC,CAAC,OAAQC,KAAK,EAAG,CAAC;EAEnB,IAAKL,QAAQ,EAAG;IACf,OAAOA,QAAQ;EAChB;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/get-filename.ts"],
4
+ "sourcesContent": ["/**\n * Returns the filename part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'\n * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'\n * ```\n *\n * @return The filename part of the URL.\n */\nexport function getFilename( url: string ): string | void {\n\tlet filename;\n\n\tif ( ! url ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tfilename = new URL( url, 'http://example.com' ).pathname\n\t\t\t.split( '/' )\n\t\t\t.pop();\n\t} catch ( error ) {}\n\n\tif ( filename ) {\n\t\treturn filename;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,YAAa,KAA6B;AACzD,MAAI;AAEJ,MAAK,CAAE,KAAM;AACZ;AAAA,EACD;AAEA,MAAI;AACH,eAAW,IAAI,IAAK,KAAK,oBAAqB,EAAE,SAC9C,MAAO,GAAI,EACX,IAAI;AAAA,EACP,SAAU,OAAQ;AAAA,EAAC;AAEnB,MAAK,UAAW;AACf,WAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -1,26 +1,34 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var get_fragment_exports = {};
20
+ __export(get_fragment_exports, {
21
+ getFragment: () => getFragment
5
22
  });
6
- exports.getFragment = getFragment;
7
- /**
8
- * Returns the fragment part of the URL.
9
- *
10
- * @param url The full URL
11
- *
12
- * @example
13
- * ```js
14
- * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
15
- * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
16
- * ```
17
- *
18
- * @return The fragment part of the URL.
19
- */
23
+ module.exports = __toCommonJS(get_fragment_exports);
20
24
  function getFragment(url) {
21
25
  const matches = /^\S+?(#[^\s\?]*)/.exec(url);
22
26
  if (matches) {
23
27
  return matches[1];
24
28
  }
25
29
  }
26
- //# sourceMappingURL=get-fragment.js.map
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ getFragment
33
+ });
34
+ //# sourceMappingURL=get-fragment.js.map