@wordpress/url 4.32.0 → 4.32.1-next.b8c8708f3.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,22 +1,26 @@
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 safe_decode_uri_exports = {};
20
+ __export(safe_decode_uri_exports, {
21
+ safeDecodeURI: () => safeDecodeURI
5
22
  });
6
- exports.safeDecodeURI = safeDecodeURI;
7
- /**
8
- * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
9
- * `decodeURI` throws an error.
10
- *
11
- * @param uri URI to decode.
12
- *
13
- * @example
14
- * ```js
15
- * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
16
- * ```
17
- *
18
- * @return Decoded URI if possible.
19
- */
23
+ module.exports = __toCommonJS(safe_decode_uri_exports);
20
24
  function safeDecodeURI(uri) {
21
25
  try {
22
26
  return decodeURI(uri);
@@ -24,4 +28,8 @@ function safeDecodeURI(uri) {
24
28
  return uri;
25
29
  }
26
30
  }
27
- //# sourceMappingURL=safe-decode-uri.js.map
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ safeDecodeURI
34
+ });
35
+ //# sourceMappingURL=safe-decode-uri.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["safeDecodeURI","uri","decodeURI","uriError"],"sources":["@wordpress/url/src/safe-decode-uri.ts"],"sourcesContent":["/**\n * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if\n * `decodeURI` throws an error.\n *\n * @param uri URI to decode.\n *\n * @example\n * ```js\n * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'\n * ```\n *\n * @return Decoded URI if possible.\n */\nexport function safeDecodeURI( uri: string ): string {\n\ttry {\n\t\treturn decodeURI( uri );\n\t} catch ( uriError ) {\n\t\treturn uri;\n\t}\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAAEC,GAAW,EAAW;EACpD,IAAI;IACH,OAAOC,SAAS,CAAED,GAAI,CAAC;EACxB,CAAC,CAAC,OAAQE,QAAQ,EAAG;IACpB,OAAOF,GAAG;EACX;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/safe-decode-uri.ts"],
4
+ "sourcesContent": ["/**\n * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if\n * `decodeURI` throws an error.\n *\n * @param uri URI to decode.\n *\n * @example\n * ```js\n * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'\n * ```\n *\n * @return Decoded URI if possible.\n */\nexport function safeDecodeURI( uri: string ): string {\n\ttry {\n\t\treturn decodeURI( uri );\n\t} catch ( uriError ) {\n\t\treturn uri;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,cAAe,KAAsB;AACpD,MAAI;AACH,WAAO,UAAW,GAAI;AAAA,EACvB,SAAU,UAAW;AACpB,WAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -1,43 +1,20 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { getQueryArgs } from './get-query-args';
5
- import { buildQueryString } from './build-query-string';
6
- import { getFragment } from './get-fragment';
7
-
8
- /**
9
- * Appends arguments as querystring to the provided URL. If the URL already
10
- * includes query arguments, the arguments are merged with (and take precedent
11
- * over) the existing set.
12
- *
13
- * @param url URL to which arguments should be appended. If omitted,
14
- * only the resulting querystring is returned.
15
- * @param args Query arguments to apply to URL.
16
- *
17
- * @example
18
- * ```js
19
- * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
20
- * ```
21
- *
22
- * @return URL with arguments applied.
23
- */
24
- export function addQueryArgs(url = '', args) {
25
- // If no arguments are to be appended, return original URL.
1
+ import { getQueryArgs } from "./get-query-args";
2
+ import { buildQueryString } from "./build-query-string";
3
+ import { getFragment } from "./get-fragment";
4
+ function addQueryArgs(url = "", args) {
26
5
  if (!args || !Object.keys(args).length) {
27
6
  return url;
28
7
  }
29
- const fragment = getFragment(url) || '';
30
- let baseUrl = url.replace(fragment, '');
31
-
32
- // Determine whether URL already had query arguments.
33
- const queryStringIndex = url.indexOf('?');
8
+ const fragment = getFragment(url) || "";
9
+ let baseUrl = url.replace(fragment, "");
10
+ const queryStringIndex = url.indexOf("?");
34
11
  if (queryStringIndex !== -1) {
35
- // Merge into existing query arguments.
36
12
  args = Object.assign(getQueryArgs(url), args);
37
-
38
- // Change working base URL to omit previous query arguments.
39
13
  baseUrl = baseUrl.substr(0, queryStringIndex);
40
14
  }
41
- return baseUrl + '?' + buildQueryString(args) + fragment;
15
+ return baseUrl + "?" + buildQueryString(args) + fragment;
42
16
  }
43
- //# sourceMappingURL=add-query-args.js.map
17
+ export {
18
+ addQueryArgs
19
+ };
20
+ //# sourceMappingURL=add-query-args.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getQueryArgs","buildQueryString","getFragment","addQueryArgs","url","args","Object","keys","length","fragment","baseUrl","replace","queryStringIndex","indexOf","assign","substr"],"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":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,WAAW,QAAQ,gBAAgB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,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,GAAGP,WAAW,CAAEE,GAAI,CAAC,IAAI,EAAE;EACzC,IAAIM,OAAO,GAAGN,GAAG,CAACO,OAAO,CAAEF,QAAQ,EAAE,EAAG,CAAC;;EAEzC;EACA,MAAMG,gBAAgB,GAAGR,GAAG,CAACS,OAAO,CAAE,GAAI,CAAC;EAC3C,IAAKD,gBAAgB,KAAK,CAAC,CAAC,EAAG;IAC9B;IACAP,IAAI,GAAGC,MAAM,CAACQ,MAAM,CAAEd,YAAY,CAAEI,GAAI,CAAC,EAAEC,IAAK,CAAC;;IAEjD;IACAK,OAAO,GAAGA,OAAO,CAACK,MAAM,CAAE,CAAC,EAAEH,gBAAiB,CAAC;EAChD;EAEA,OAAOF,OAAO,GAAG,GAAG,GAAGT,gBAAgB,CAAEI,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": "AAGA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAkBrB,SAAS,aACf,MAAc,IACd,MACS;AAET,MAAK,CAAE,QAAQ,CAAE,OAAO,KAAM,IAAK,EAAE,QAAS;AAC7C,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,YAAa,GAAI,KAAK;AACvC,MAAI,UAAU,IAAI,QAAS,UAAU,EAAG;AAGxC,QAAM,mBAAmB,IAAI,QAAS,GAAI;AAC1C,MAAK,qBAAqB,IAAK;AAE9B,WAAO,OAAO,OAAQ,aAAc,GAAI,GAAG,IAAK;AAGhD,cAAU,QAAQ,OAAQ,GAAG,gBAAiB;AAAA,EAC/C;AAEA,SAAO,UAAU,MAAM,iBAAkB,IAAK,IAAI;AACnD;",
6
+ "names": []
7
+ }
@@ -1,56 +1,25 @@
1
- /**
2
- * Generates URL-encoded query string using input query data.
3
- *
4
- * It is intended to behave equivalent as PHP's `http_build_query`, configured
5
- * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).
6
- *
7
- * @example
8
- * ```js
9
- * const queryString = buildQueryString( {
10
- * simple: 'is ok',
11
- * arrays: [ 'are', 'fine', 'too' ],
12
- * objects: {
13
- * evenNested: {
14
- * ok: 'yes',
15
- * },
16
- * },
17
- * } );
18
- * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
19
- * ```
20
- *
21
- * @param data Data to encode.
22
- *
23
- * @return Query string.
24
- */
25
- export function buildQueryString(data) {
26
- let string = '';
1
+ function buildQueryString(data) {
2
+ let string = "";
27
3
  const stack = Object.entries(data);
28
4
  let pair;
29
5
  while (pair = stack.shift()) {
30
6
  let [key, value] = pair;
31
-
32
- // Support building deeply nested data, from array or object values.
33
7
  const hasNestedData = Array.isArray(value) || value && value.constructor === Object;
34
8
  if (hasNestedData) {
35
- // Push array or object values onto the stack as composed of their
36
- // original key and nested index or key, retaining order by a
37
- // combination of Array#reverse and Array#unshift onto the stack.
38
9
  const valuePairs = Object.entries(value).reverse();
39
10
  for (const [member, memberValue] of valuePairs) {
40
11
  stack.unshift([`${key}[${member}]`, memberValue]);
41
12
  }
42
- } else if (value !== undefined) {
43
- // Null is treated as special case, equivalent to empty string.
13
+ } else if (value !== void 0) {
44
14
  if (value === null) {
45
- value = '';
15
+ value = "";
46
16
  }
47
- string += '&' + [key, String(value)].map(encodeURIComponent).join('=');
17
+ string += "&" + [key, String(value)].map(encodeURIComponent).join("=");
48
18
  }
49
19
  }
50
-
51
- // Loop will concatenate with leading `&`, but it's only expected for all
52
- // but the first query parameter. This strips the leading `&`, while still
53
- // accounting for the case that the string may in-fact be empty.
54
20
  return string.substr(1);
55
21
  }
56
- //# sourceMappingURL=build-query-string.js.map
22
+ export {
23
+ buildQueryString
24
+ };
25
+ //# 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;AACA,OAAO,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": "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,42 +1,11 @@
1
- /**
2
- * External dependencies
3
- */
4
- import removeAccents from 'remove-accents';
5
-
6
- /**
7
- * Performs some basic cleanup of a string for use as a post slug.
8
- *
9
- * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but
10
- * is only designed to approximate what the slug will be.
11
- *
12
- * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin
13
- * letters. Removes combining diacritical marks. Converts whitespace, periods,
14
- * and forward slashes to hyphens. Removes any remaining non-word characters
15
- * except hyphens. Converts remaining string to lowercase. It does not account
16
- * for octets, HTML entities, or other encoded characters.
17
- *
18
- * @param string Title or slug to be processed.
19
- *
20
- * @return Processed string.
21
- */
22
- export function cleanForSlug(string) {
1
+ import removeAccents from "remove-accents";
2
+ function cleanForSlug(string) {
23
3
  if (!string) {
24
- return '';
4
+ return "";
25
5
  }
26
- return removeAccents(string)
27
- // Convert &nbsp, &ndash, and &mdash to hyphens.
28
- .replace(/(&nbsp;|&ndash;|&mdash;)/g, '-')
29
- // Convert each group of whitespace, periods, and forward slashes to a hyphen.
30
- .replace(/[\s\./]+/g, '-')
31
- // Remove all HTML entities.
32
- .replace(/&\S+?;/g, '')
33
- // Remove anything that's not a letter, number, underscore or hyphen.
34
- .replace(/[^\p{L}\p{N}_-]+/gu, '')
35
- // Convert to lowercase
36
- .toLowerCase()
37
- // Replace multiple hyphens with a single one.
38
- .replace(/-+/g, '-')
39
- // Remove any remaining leading or trailing hyphens.
40
- .replace(/(^-+)|(-+$)/g, '');
6
+ return removeAccents(string).replace(/(&nbsp;|&ndash;|&mdash;)/g, "-").replace(/[\s\./]+/g, "-").replace(/&\S+?;/g, "").replace(/[^\p{L}\p{N}_-]+/gu, "").toLowerCase().replace(/-+/g, "-").replace(/(^-+)|(-+$)/g, "");
41
7
  }
42
- //# sourceMappingURL=clean-for-slug.js.map
8
+ export {
9
+ cleanForSlug
10
+ };
11
+ //# sourceMappingURL=clean-for-slug.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["removeAccents","cleanForSlug","string","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":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,MAAc,EAAW;EACtD,IAAK,CAAEA,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EACA,OACCF,aAAa,CAAEE,MAAO;EACrB;EAAA,CACCC,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": "AAGA,OAAO,mBAAmB;AAkBnB,SAAS,aAAc,QAAyB;AACtD,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AACA,SACC,cAAe,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": []
7
+ }
@@ -1,48 +1,30 @@
1
- /**
2
- * Returns a URL for display.
3
- *
4
- * @param url Original URL.
5
- * @param maxLength URL length.
6
- *
7
- * @example
8
- * ```js
9
- * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
10
- * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
11
- * ```
12
- *
13
- * @return Displayed URL.
14
- */
15
- export function filterURLForDisplay(url, maxLength = null) {
1
+ function filterURLForDisplay(url, maxLength = null) {
16
2
  if (!url) {
17
- return '';
3
+ return "";
18
4
  }
19
-
20
- // Remove protocol and www prefixes.
21
- let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, '').replace(/^www\./i, '');
22
-
23
- // Ends with / and only has that single slash, strip it.
5
+ let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, "").replace(/^www\./i, "");
24
6
  if (filteredURL.match(/^[^\/]+\/$/)) {
25
- filteredURL = filteredURL.replace('/', '');
7
+ filteredURL = filteredURL.replace("/", "");
26
8
  }
27
-
28
- // capture file name from URL
29
9
  const fileRegexp = /\/([^\/?]+)\.(?:[\w]+)(?=\?|$)/;
30
10
  if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(fileRegexp)) {
31
11
  return filteredURL;
32
12
  }
33
-
34
- // If the file is not greater than max length, return last portion of URL.
35
- filteredURL = filteredURL.split('?')[0];
36
- const urlPieces = filteredURL.split('/');
13
+ filteredURL = filteredURL.split("?")[0];
14
+ const urlPieces = filteredURL.split("/");
37
15
  const file = urlPieces[urlPieces.length - 1];
38
16
  if (file.length <= maxLength) {
39
- return '…' + filteredURL.slice(-maxLength);
17
+ return "\u2026" + filteredURL.slice(-maxLength);
40
18
  }
41
-
42
- // If the file is greater than max length, truncate the file.
43
- const index = file.lastIndexOf('.');
44
- const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)];
45
- const truncatedFile = fileName.slice(-3) + '.' + extension;
46
- return file.slice(0, maxLength - truncatedFile.length - 1) + '…' + truncatedFile;
19
+ const index = file.lastIndexOf(".");
20
+ const [fileName, extension] = [
21
+ file.slice(0, index),
22
+ file.slice(index + 1)
23
+ ];
24
+ const truncatedFile = fileName.slice(-3) + "." + extension;
25
+ return file.slice(0, maxLength - truncatedFile.length - 1) + "\u2026" + truncatedFile;
47
26
  }
48
- //# sourceMappingURL=filter-url-for-display.js.map
27
+ export {
28
+ filterURLForDisplay
29
+ };
30
+ //# 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;AACA,OAAO,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": "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,20 +1,12 @@
1
- /**
2
- * Returns the authority part of the URL.
3
- *
4
- * @param url The full URL.
5
- *
6
- * @example
7
- * ```js
8
- * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'
9
- * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
10
- * ```
11
- *
12
- * @return The authority part of the URL.
13
- */
14
- export function getAuthority(url) {
15
- const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
1
+ function getAuthority(url) {
2
+ const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(
3
+ url
4
+ );
16
5
  if (matches) {
17
6
  return matches[1];
18
7
  }
19
8
  }
20
- //# sourceMappingURL=get-authority.js.map
9
+ export {
10
+ getAuthority
11
+ };
12
+ //# 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;AACA,OAAO,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": "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,27 +1,17 @@
1
- /* wp:polyfill */
2
- /**
3
- * Returns the filename part of the URL.
4
- *
5
- * @param url The full URL.
6
- *
7
- * @example
8
- * ```js
9
- * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'
10
- * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
11
- * ```
12
- *
13
- * @return The filename part of the URL.
14
- */
15
- export function getFilename(url) {
1
+ function getFilename(url) {
16
2
  let filename;
17
3
  if (!url) {
18
4
  return;
19
5
  }
20
6
  try {
21
- filename = new URL(url, 'http://example.com').pathname.split('/').pop();
22
- } catch (error) {}
7
+ filename = new URL(url, "http://example.com").pathname.split("/").pop();
8
+ } catch (error) {
9
+ }
23
10
  if (filename) {
24
11
  return filename;
25
12
  }
26
13
  }
27
- //# sourceMappingURL=get-filename.js.map
14
+ export {
15
+ getFilename
16
+ };
17
+ //# 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;AACA,OAAO,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": "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,20 +1,10 @@
1
- /**
2
- * Returns the fragment part of the URL.
3
- *
4
- * @param url The full URL
5
- *
6
- * @example
7
- * ```js
8
- * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
9
- * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
10
- * ```
11
- *
12
- * @return The fragment part of the URL.
13
- */
14
- export function getFragment(url) {
1
+ function getFragment(url) {
15
2
  const matches = /^\S+?(#[^\s\?]*)/.exec(url);
16
3
  if (matches) {
17
4
  return matches[1];
18
5
  }
19
6
  }
20
- //# sourceMappingURL=get-fragment.js.map
7
+ export {
8
+ getFragment
9
+ };
10
+ //# sourceMappingURL=get-fragment.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getFragment","url","matches","exec"],"sources":["@wordpress/url/src/get-fragment.ts"],"sourcesContent":["/**\n * Returns the fragment part of the URL.\n *\n * @param url The full URL\n *\n * @example\n * ```js\n * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'\n * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'\n * ```\n *\n * @return The fragment part of the URL.\n */\nexport function getFragment( url: string ): string | void {\n\tconst matches = /^\\S+?(#[^\\s\\?]*)/.exec( url );\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;AACA,OAAO,SAASA,WAAWA,CAAEC,GAAW,EAAkB;EACzD,MAAMC,OAAO,GAAG,kBAAkB,CAACC,IAAI,CAAEF,GAAI,CAAC;EAC9C,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/get-fragment.ts"],
4
+ "sourcesContent": ["/**\n * Returns the fragment part of the URL.\n *\n * @param url The full URL\n *\n * @example\n * ```js\n * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'\n * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'\n * ```\n *\n * @return The fragment part of the URL.\n */\nexport function getFragment( url: string ): string | void {\n\tconst matches = /^\\S+?(#[^\\s\\?]*)/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
5
+ "mappings": "AAaO,SAAS,YAAa,KAA6B;AACzD,QAAM,UAAU,mBAAmB,KAAM,GAAI;AAC7C,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
6
+ "names": []
7
+ }
@@ -1,25 +1,8 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { getPath, getQueryString } from '.';
5
-
6
- /**
7
- * Returns the path part and query string part of the URL.
8
- *
9
- * @param url The full URL.
10
- *
11
- * @example
12
- * ```js
13
- * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
14
- * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
15
- * ```
16
- *
17
- * @return The path part and query string part of the URL.
18
- */
19
- export function getPathAndQueryString(url) {
1
+ import { getPath, getQueryString } from ".";
2
+ function getPathAndQueryString(url) {
20
3
  const path = getPath(url);
21
4
  const queryString = getQueryString(url);
22
- let value = '/';
5
+ let value = "/";
23
6
  if (path) {
24
7
  value += path;
25
8
  }
@@ -28,4 +11,7 @@ export function getPathAndQueryString(url) {
28
11
  }
29
12
  return value;
30
13
  }
31
- //# sourceMappingURL=get-path-and-query-string.js.map
14
+ export {
15
+ getPathAndQueryString
16
+ };
17
+ //# sourceMappingURL=get-path-and-query-string.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getPath","getQueryString","getPathAndQueryString","url","path","queryString","value"],"sources":["@wordpress/url/src/get-path-and-query-string.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getPath, getQueryString } from '.';\n\n/**\n * Returns the path part and query string part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'\n * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'\n * ```\n *\n * @return The path part and query string part of the URL.\n */\nexport function getPathAndQueryString( url: string ): string {\n\tconst path = getPath( url );\n\tconst queryString = getQueryString( url );\n\tlet value = '/';\n\tif ( path ) {\n\t\tvalue += path;\n\t}\n\tif ( queryString ) {\n\t\tvalue += `?${ queryString }`;\n\t}\n\treturn value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,cAAc,QAAQ,GAAG;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAAEC,GAAW,EAAW;EAC5D,MAAMC,IAAI,GAAGJ,OAAO,CAAEG,GAAI,CAAC;EAC3B,MAAME,WAAW,GAAGJ,cAAc,CAAEE,GAAI,CAAC;EACzC,IAAIG,KAAK,GAAG,GAAG;EACf,IAAKF,IAAI,EAAG;IACXE,KAAK,IAAIF,IAAI;EACd;EACA,IAAKC,WAAW,EAAG;IAClBC,KAAK,IAAI,IAAKD,WAAW,EAAG;EAC7B;EACA,OAAOC,KAAK;AACb","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/get-path-and-query-string.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getPath, getQueryString } from '.';\n\n/**\n * Returns the path part and query string part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'\n * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'\n * ```\n *\n * @return The path part and query string part of the URL.\n */\nexport function getPathAndQueryString( url: string ): string {\n\tconst path = getPath( url );\n\tconst queryString = getQueryString( url );\n\tlet value = '/';\n\tif ( path ) {\n\t\tvalue += path;\n\t}\n\tif ( queryString ) {\n\t\tvalue += `?${ queryString }`;\n\t}\n\treturn value;\n}\n"],
5
+ "mappings": "AAGA,SAAS,SAAS,sBAAsB;AAejC,SAAS,sBAAuB,KAAsB;AAC5D,QAAM,OAAO,QAAS,GAAI;AAC1B,QAAM,cAAc,eAAgB,GAAI;AACxC,MAAI,QAAQ;AACZ,MAAK,MAAO;AACX,aAAS;AAAA,EACV;AACA,MAAK,aAAc;AAClB,aAAS,IAAK,WAAY;AAAA,EAC3B;AACA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,20 +1,10 @@
1
- /**
2
- * Returns the path part of the URL.
3
- *
4
- * @param url The full URL.
5
- *
6
- * @example
7
- * ```js
8
- * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'
9
- * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'
10
- * ```
11
- *
12
- * @return The path part of the URL.
13
- */
14
- export function getPath(url) {
1
+ function getPath(url) {
15
2
  const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
16
3
  if (matches) {
17
4
  return matches[1];
18
5
  }
19
6
  }
20
- //# sourceMappingURL=get-path.js.map
7
+ export {
8
+ getPath
9
+ };
10
+ //# sourceMappingURL=get-path.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getPath","url","matches","exec"],"sources":["@wordpress/url/src/get-path.ts"],"sourcesContent":["/**\n * Returns the path part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'\n * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'\n * ```\n *\n * @return The path part of the URL.\n */\nexport function getPath( url: string ): string | void {\n\tconst matches =\n\t\t/^[^\\/\\s:]+:(?:\\/\\/)?[^\\/\\s#?]+[\\/]([^\\s#?]+)[#?]{0,1}\\S*$/.exec( url );\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;AACA,OAAO,SAASA,OAAOA,CAAEC,GAAW,EAAkB;EACrD,MAAMC,OAAO,GACZ,2DAA2D,CAACC,IAAI,CAAEF,GAAI,CAAC;EACxE,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/get-path.ts"],
4
+ "sourcesContent": ["/**\n * Returns the path part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'\n * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'\n * ```\n *\n * @return The path part of the URL.\n */\nexport function getPath( url: string ): string | void {\n\tconst matches =\n\t\t/^[^\\/\\s:]+:(?:\\/\\/)?[^\\/\\s#?]+[\\/]([^\\s#?]+)[#?]{0,1}\\S*$/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
5
+ "mappings": "AAaO,SAAS,QAAS,KAA6B;AACrD,QAAM,UACL,4DAA4D,KAAM,GAAI;AACvE,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
6
+ "names": []
7
+ }