@wordpress/url 3.40.0 → 3.41.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 (111) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/add-query-args.js +4 -8
  3. package/build/add-query-args.js.map +1 -1
  4. package/build/build-query-string.js +5 -9
  5. package/build/build-query-string.js.map +1 -1
  6. package/build/clean-for-slug.js +10 -9
  7. package/build/clean-for-slug.js.map +1 -1
  8. package/build/filter-url-for-display.js +6 -9
  9. package/build/filter-url-for-display.js.map +1 -1
  10. package/build/get-authority.js +0 -2
  11. package/build/get-authority.js.map +1 -1
  12. package/build/get-filename.js +0 -3
  13. package/build/get-filename.js.map +1 -1
  14. package/build/get-fragment.js +0 -2
  15. package/build/get-fragment.js.map +1 -1
  16. package/build/get-path-and-query-string.js +0 -2
  17. package/build/get-path-and-query-string.js.map +1 -1
  18. package/build/get-path.js +0 -2
  19. package/build/get-path.js.map +1 -1
  20. package/build/get-protocol.js +0 -2
  21. package/build/get-protocol.js.map +1 -1
  22. package/build/get-query-arg.js +0 -2
  23. package/build/get-query-arg.js.map +1 -1
  24. package/build/get-query-args.js +15 -19
  25. package/build/get-query-args.js.map +1 -1
  26. package/build/get-query-string.js +0 -3
  27. package/build/get-query-string.js.map +1 -1
  28. package/build/has-query-arg.js +0 -2
  29. package/build/has-query-arg.js.map +1 -1
  30. package/build/index.js +0 -27
  31. package/build/index.js.map +1 -1
  32. package/build/is-email.js +1 -1
  33. package/build/is-email.js.map +1 -1
  34. package/build/is-url.js +0 -1
  35. package/build/is-url.js.map +1 -1
  36. package/build/is-valid-authority.js +0 -2
  37. package/build/is-valid-authority.js.map +1 -1
  38. package/build/is-valid-fragment.js +0 -2
  39. package/build/is-valid-fragment.js.map +1 -1
  40. package/build/is-valid-path.js +0 -2
  41. package/build/is-valid-path.js.map +1 -1
  42. package/build/is-valid-protocol.js +0 -2
  43. package/build/is-valid-protocol.js.map +1 -1
  44. package/build/is-valid-query-string.js +0 -2
  45. package/build/is-valid-query-string.js.map +1 -1
  46. package/build/normalize-path.js +16 -11
  47. package/build/normalize-path.js.map +1 -1
  48. package/build/prepend-http.js +2 -6
  49. package/build/prepend-http.js.map +1 -1
  50. package/build/prepend-https.js +2 -5
  51. package/build/prepend-https.js.map +1 -1
  52. package/build/remove-query-args.js +0 -5
  53. package/build/remove-query-args.js.map +1 -1
  54. package/build/safe-decode-uri-component.js +0 -1
  55. package/build/safe-decode-uri-component.js.map +1 -1
  56. package/build/safe-decode-uri.js +0 -1
  57. package/build/safe-decode-uri.js.map +1 -1
  58. package/build-module/add-query-args.js +5 -6
  59. package/build-module/add-query-args.js.map +1 -1
  60. package/build-module/build-query-string.js +5 -8
  61. package/build-module/build-query-string.js.map +1 -1
  62. package/build-module/clean-for-slug.js +11 -7
  63. package/build-module/clean-for-slug.js.map +1 -1
  64. package/build-module/filter-url-for-display.js +6 -8
  65. package/build-module/filter-url-for-display.js.map +1 -1
  66. package/build-module/get-authority.js +0 -1
  67. package/build-module/get-authority.js.map +1 -1
  68. package/build-module/get-filename.js +0 -2
  69. package/build-module/get-filename.js.map +1 -1
  70. package/build-module/get-fragment.js +0 -1
  71. package/build-module/get-fragment.js.map +1 -1
  72. package/build-module/get-path-and-query-string.js +1 -1
  73. package/build-module/get-path-and-query-string.js.map +1 -1
  74. package/build-module/get-path.js +0 -1
  75. package/build-module/get-path.js.map +1 -1
  76. package/build-module/get-protocol.js +0 -1
  77. package/build-module/get-protocol.js.map +1 -1
  78. package/build-module/get-query-arg.js +1 -1
  79. package/build-module/get-query-arg.js.map +1 -1
  80. package/build-module/get-query-args.js +16 -17
  81. package/build-module/get-query-args.js.map +1 -1
  82. package/build-module/get-query-string.js +0 -2
  83. package/build-module/get-query-string.js.map +1 -1
  84. package/build-module/has-query-arg.js +1 -1
  85. package/build-module/has-query-arg.js.map +1 -1
  86. package/build-module/index.js.map +1 -1
  87. package/build-module/is-email.js +1 -1
  88. package/build-module/is-email.js.map +1 -1
  89. package/build-module/is-url.js.map +1 -1
  90. package/build-module/is-valid-authority.js +0 -1
  91. package/build-module/is-valid-authority.js.map +1 -1
  92. package/build-module/is-valid-fragment.js +0 -1
  93. package/build-module/is-valid-fragment.js.map +1 -1
  94. package/build-module/is-valid-path.js +0 -1
  95. package/build-module/is-valid-path.js.map +1 -1
  96. package/build-module/is-valid-protocol.js +0 -1
  97. package/build-module/is-valid-protocol.js.map +1 -1
  98. package/build-module/is-valid-query-string.js +0 -1
  99. package/build-module/is-valid-query-string.js.map +1 -1
  100. package/build-module/normalize-path.js +16 -10
  101. package/build-module/normalize-path.js.map +1 -1
  102. package/build-module/prepend-http.js +1 -4
  103. package/build-module/prepend-http.js.map +1 -1
  104. package/build-module/prepend-https.js +3 -4
  105. package/build-module/prepend-https.js.map +1 -1
  106. package/build-module/remove-query-args.js +1 -3
  107. package/build-module/remove-query-args.js.map +1 -1
  108. package/build-module/safe-decode-uri-component.js.map +1 -1
  109. package/build-module/safe-decode-uri.js.map +1 -1
  110. package/package.json +3 -3
  111. package/tsconfig.tsbuildinfo +1 -1
@@ -14,28 +14,26 @@
14
14
  */
15
15
  export function filterURLForDisplay(url, maxLength = null) {
16
16
  // Remove protocol and www prefixes.
17
- let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, ''); // Ends with / and only has that single slash, strip it.
17
+ let filteredURL = url.replace(/^(?:https?:)\/\/(?:www\.)?/, '');
18
18
 
19
+ // Ends with / and only has that single slash, strip it.
19
20
  if (filteredURL.match(/^[^\/]+\/$/)) {
20
21
  filteredURL = filteredURL.replace('/', '');
21
22
  }
22
-
23
23
  const mediaRegexp = /([\w|:])*\.(?:jpg|jpeg|gif|png|svg)/;
24
-
25
24
  if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(mediaRegexp)) {
26
25
  return filteredURL;
27
- } // If the file is not greater than max length, return last portion of URL.
28
-
26
+ }
29
27
 
28
+ // If the file is not greater than max length, return last portion of URL.
30
29
  filteredURL = filteredURL.split('?')[0];
31
30
  const urlPieces = filteredURL.split('/');
32
31
  const file = urlPieces[urlPieces.length - 1];
33
-
34
32
  if (file.length <= maxLength) {
35
33
  return '…' + filteredURL.slice(-maxLength);
36
- } // If the file is greater than max length, truncate the file.
37
-
34
+ }
38
35
 
36
+ // If the file is greater than max length, truncate the file.
39
37
  const index = file.lastIndexOf('.');
40
38
  const [fileName, extension] = [file.slice(0, index), file.slice(index + 1)];
41
39
  const truncatedFile = fileName.slice(-3) + '.' + extension;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/filter-url-for-display.js"],"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","mediaRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAT,CAA8BC,GAA9B,EAAmCC,SAAS,GAAG,IAA/C,EAAsD;AAC5D;AACA,MAAIC,WAAW,GAAGF,GAAG,CAACG,OAAJ,CAAa,4BAAb,EAA2C,EAA3C,CAAlB,CAF4D,CAI5D;;AACA,MAAKD,WAAW,CAACE,KAAZ,CAAmB,YAAnB,CAAL,EAAyC;AACxCF,IAAAA,WAAW,GAAGA,WAAW,CAACC,OAAZ,CAAqB,GAArB,EAA0B,EAA1B,CAAd;AACA;;AAED,QAAME,WAAW,GAAG,qCAApB;;AAEA,MACC,CAAEJ,SAAF,IACAC,WAAW,CAACI,MAAZ,IAAsBL,SADtB,IAEA,CAAEC,WAAW,CAACE,KAAZ,CAAmBC,WAAnB,CAHH,EAIE;AACD,WAAOH,WAAP;AACA,GAjB2D,CAmB5D;;;AACAA,EAAAA,WAAW,GAAGA,WAAW,CAACK,KAAZ,CAAmB,GAAnB,EAA0B,CAA1B,CAAd;AACA,QAAMC,SAAS,GAAGN,WAAW,CAACK,KAAZ,CAAmB,GAAnB,CAAlB;AACA,QAAME,IAAI,GAAGD,SAAS,CAAEA,SAAS,CAACF,MAAV,GAAmB,CAArB,CAAtB;;AACA,MAAKG,IAAI,CAACH,MAAL,IAAeL,SAApB,EAAgC;AAC/B,WAAO,MAAMC,WAAW,CAACQ,KAAZ,CAAmB,CAACT,SAApB,CAAb;AACA,GAzB2D,CA2B5D;;;AACA,QAAMU,KAAK,GAAGF,IAAI,CAACG,WAAL,CAAkB,GAAlB,CAAd;AACA,QAAM,CAAEC,QAAF,EAAYC,SAAZ,IAA0B,CAC/BL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeC,KAAf,CAD+B,EAE/BF,IAAI,CAACC,KAAL,CAAYC,KAAK,GAAG,CAApB,CAF+B,CAAhC;AAIA,QAAMI,aAAa,GAAGF,QAAQ,CAACH,KAAT,CAAgB,CAAC,CAAjB,IAAuB,GAAvB,GAA6BI,SAAnD;AACA,SACCL,IAAI,CAACC,KAAL,CAAY,CAAZ,EAAeT,SAAS,GAAGc,aAAa,CAACT,MAA1B,GAAmC,CAAlD,IACA,GADA,GAEAS,aAHD;AAKA","sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param {string} url Original URL.\n * @param {number|null} 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 {string} Displayed URL.\n */\nexport function filterURLForDisplay( url, maxLength = null ) {\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url.replace( /^(?:https?:)\\/\\/(?:www\\.)?/, '' );\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\tconst mediaRegexp = /([\\w|:])*\\.(?:jpg|jpeg|gif|png|svg)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( mediaRegexp )\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"]}
1
+ {"version":3,"names":["filterURLForDisplay","url","maxLength","filteredURL","replace","match","mediaRegexp","length","split","urlPieces","file","slice","index","lastIndexOf","fileName","extension","truncatedFile"],"sources":["@wordpress/url/src/filter-url-for-display.js"],"sourcesContent":["/**\n * Returns a URL for display.\n *\n * @param {string} url Original URL.\n * @param {number|null} 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 {string} Displayed URL.\n */\nexport function filterURLForDisplay( url, maxLength = null ) {\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url.replace( /^(?:https?:)\\/\\/(?:www\\.)?/, '' );\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\tconst mediaRegexp = /([\\w|:])*\\.(?:jpg|jpeg|gif|png|svg)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( mediaRegexp )\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,CAAEC,GAAG,EAAEC,SAAS,GAAG,IAAI,EAAG;EAC5D;EACA,IAAIC,WAAW,GAAGF,GAAG,CAACG,OAAO,CAAE,4BAA4B,EAAE,EAAG,CAAC;;EAEjE;EACA,IAAKD,WAAW,CAACE,KAAK,CAAE,YAAa,CAAC,EAAG;IACxCF,WAAW,GAAGA,WAAW,CAACC,OAAO,CAAE,GAAG,EAAE,EAAG,CAAC;EAC7C;EAEA,MAAME,WAAW,GAAG,qCAAqC;EAEzD,IACC,CAAEJ,SAAS,IACXC,WAAW,CAACI,MAAM,IAAIL,SAAS,IAC/B,CAAEC,WAAW,CAACE,KAAK,CAAEC,WAAY,CAAC,EACjC;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"}
@@ -13,7 +13,6 @@
13
13
  */
14
14
  export function getAuthority(url) {
15
15
  const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
16
-
17
16
  if (matches) {
18
17
  return matches[1];
19
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-authority.js"],"names":["getAuthority","url","matches","exec"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAT,CAAuBC,GAAvB,EAA6B;AACnC,QAAMC,OAAO,GAAG,qDAAqDC,IAArD,CACfF,GADe,CAAhB;;AAGA,MAAKC,OAAL,EAAe;AACd,WAAOA,OAAO,CAAE,CAAF,CAAd;AACA;AACD","sourcesContent":["/**\n * Returns the authority part of the URL.\n *\n * @param {string} 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 {string|void} The authority part of the URL.\n */\nexport function getAuthority( url ) {\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"]}
1
+ {"version":3,"names":["getAuthority","url","matches","exec"],"sources":["@wordpress/url/src/get-authority.js"],"sourcesContent":["/**\n * Returns the authority part of the URL.\n *\n * @param {string} 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 {string|void} The authority part of the URL.\n */\nexport function getAuthority( url ) {\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,GAAG,EAAG;EACnC,MAAMC,OAAO,GAAG,oDAAoD,CAACC,IAAI,CACxEF,GACD,CAAC;EACD,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD"}
@@ -13,11 +13,9 @@
13
13
  */
14
14
  export function getFilename(url) {
15
15
  let filename;
16
-
17
16
  try {
18
17
  filename = new URL(url, 'http://example.com').pathname.split('/').pop();
19
18
  } catch (error) {}
20
-
21
19
  if (filename) {
22
20
  return filename;
23
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-filename.js"],"names":["getFilename","url","filename","URL","pathname","split","pop","error"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAT,CAAsBC,GAAtB,EAA4B;AAClC,MAAIC,QAAJ;;AACA,MAAI;AACHA,IAAAA,QAAQ,GAAG,IAAIC,GAAJ,CAASF,GAAT,EAAc,oBAAd,EAAqCG,QAArC,CACTC,KADS,CACF,GADE,EAETC,GAFS,EAAX;AAGA,GAJD,CAIE,OAAQC,KAAR,EAAgB,CAAE;;AAEpB,MAAKL,QAAL,EAAgB;AACf,WAAOA,QAAP;AACA;AACD","sourcesContent":["/**\n * Returns the filename part of the URL.\n *\n * @param {string} 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 {string|void} The filename part of the URL.\n */\nexport function getFilename( url ) {\n\tlet filename;\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"]}
1
+ {"version":3,"names":["getFilename","url","filename","URL","pathname","split","pop","error"],"sources":["@wordpress/url/src/get-filename.js"],"sourcesContent":["/**\n * Returns the filename part of the URL.\n *\n * @param {string} 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 {string|void} The filename part of the URL.\n */\nexport function getFilename( url ) {\n\tlet filename;\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,GAAG,EAAG;EAClC,IAAIC,QAAQ;EACZ,IAAI;IACHA,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"}
@@ -13,7 +13,6 @@
13
13
  */
14
14
  export function getFragment(url) {
15
15
  const matches = /^\S+?(#[^\s\?]*)/.exec(url);
16
-
17
16
  if (matches) {
18
17
  return matches[1];
19
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-fragment.js"],"names":["getFragment","url","matches","exec"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAT,CAAsBC,GAAtB,EAA4B;AAClC,QAAMC,OAAO,GAAG,mBAAmBC,IAAnB,CAAyBF,GAAzB,CAAhB;;AACA,MAAKC,OAAL,EAAe;AACd,WAAOA,OAAO,CAAE,CAAF,CAAd;AACA;AACD","sourcesContent":["/**\n * Returns the fragment part of the URL.\n *\n * @param {string} 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 {string|void} The fragment part of the URL.\n */\nexport function getFragment( url ) {\n\tconst matches = /^\\S+?(#[^\\s\\?]*)/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"]}
1
+ {"version":3,"names":["getFragment","url","matches","exec"],"sources":["@wordpress/url/src/get-fragment.js"],"sourcesContent":["/**\n * Returns the fragment part of the URL.\n *\n * @param {string} 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 {string|void} The fragment part of the URL.\n */\nexport function getFragment( url ) {\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,GAAG,EAAG;EAClC,MAAMC,OAAO,GAAG,kBAAkB,CAACC,IAAI,CAAEF,GAAI,CAAC;EAC9C,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD"}
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import { getPath, getQueryString } from '.';
5
+
5
6
  /**
6
7
  * Returns the path part and query string part of the URL.
7
8
  *
@@ -15,7 +16,6 @@ import { getPath, getQueryString } from '.';
15
16
  *
16
17
  * @return {string} The path part and query string part of the URL.
17
18
  */
18
-
19
19
  export function getPathAndQueryString(url) {
20
20
  const path = getPath(url);
21
21
  const queryString = getQueryString(url);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-path-and-query-string.js"],"names":["getPath","getQueryString","getPathAndQueryString","url","path","queryString","value"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,cAAlB,QAAwC,GAAxC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCC,GAAhC,EAAsC;AAC5C,QAAMC,IAAI,GAAGJ,OAAO,CAAEG,GAAF,CAApB;AACA,QAAME,WAAW,GAAGJ,cAAc,CAAEE,GAAF,CAAlC;AACA,MAAIG,KAAK,GAAG,GAAZ;AACA,MAAKF,IAAL,EAAYE,KAAK,IAAIF,IAAT;AACZ,MAAKC,WAAL,EAAmBC,KAAK,IAAK,IAAID,WAAa,EAA3B;AACnB,SAAOC,KAAP;AACA","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 {string} 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 {string} The path part and query string part of the URL.\n */\nexport function getPathAndQueryString( url ) {\n\tconst path = getPath( url );\n\tconst queryString = getQueryString( url );\n\tlet value = '/';\n\tif ( path ) value += path;\n\tif ( queryString ) value += `?${ queryString }`;\n\treturn value;\n}\n"]}
1
+ {"version":3,"names":["getPath","getQueryString","getPathAndQueryString","url","path","queryString","value"],"sources":["@wordpress/url/src/get-path-and-query-string.js"],"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 {string} 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 {string} The path part and query string part of the URL.\n */\nexport function getPathAndQueryString( url ) {\n\tconst path = getPath( url );\n\tconst queryString = getQueryString( url );\n\tlet value = '/';\n\tif ( path ) value += path;\n\tif ( queryString ) value += `?${ queryString }`;\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,GAAG,EAAG;EAC5C,MAAMC,IAAI,GAAGJ,OAAO,CAAEG,GAAI,CAAC;EAC3B,MAAME,WAAW,GAAGJ,cAAc,CAAEE,GAAI,CAAC;EACzC,IAAIG,KAAK,GAAG,GAAG;EACf,IAAKF,IAAI,EAAGE,KAAK,IAAIF,IAAI;EACzB,IAAKC,WAAW,EAAGC,KAAK,IAAK,IAAID,WAAa,EAAC;EAC/C,OAAOC,KAAK;AACb"}
@@ -13,7 +13,6 @@
13
13
  */
14
14
  export function getPath(url) {
15
15
  const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
16
-
17
16
  if (matches) {
18
17
  return matches[1];
19
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-path.js"],"names":["getPath","url","matches","exec"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,OAAT,CAAkBC,GAAlB,EAAwB;AAC9B,QAAMC,OAAO,GACZ,4DAA4DC,IAA5D,CAAkEF,GAAlE,CADD;;AAEA,MAAKC,OAAL,EAAe;AACd,WAAOA,OAAO,CAAE,CAAF,CAAd;AACA;AACD","sourcesContent":["/**\n * Returns the path part of the URL.\n *\n * @param {string} 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 {string|void} The path part of the URL.\n */\nexport function getPath( url ) {\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"]}
1
+ {"version":3,"names":["getPath","url","matches","exec"],"sources":["@wordpress/url/src/get-path.js"],"sourcesContent":["/**\n * Returns the path part of the URL.\n *\n * @param {string} 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 {string|void} The path part of the URL.\n */\nexport function getPath( url ) {\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,GAAG,EAAG;EAC9B,MAAMC,OAAO,GACZ,2DAA2D,CAACC,IAAI,CAAEF,GAAI,CAAC;EACxE,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD"}
@@ -13,7 +13,6 @@
13
13
  */
14
14
  export function getProtocol(url) {
15
15
  const matches = /^([^\s:]+:)/.exec(url);
16
-
17
16
  if (matches) {
18
17
  return matches[1];
19
18
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-protocol.js"],"names":["getProtocol","url","matches","exec"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAT,CAAsBC,GAAtB,EAA4B;AAClC,QAAMC,OAAO,GAAG,cAAcC,IAAd,CAAoBF,GAApB,CAAhB;;AACA,MAAKC,OAAL,EAAe;AACd,WAAOA,OAAO,CAAE,CAAF,CAAd;AACA;AACD","sourcesContent":["/**\n * Returns the protocol part of the URL.\n *\n * @param {string} url The full URL.\n *\n * @example\n * ```js\n * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'\n * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'\n * ```\n *\n * @return {string|void} The protocol part of the URL.\n */\nexport function getProtocol( url ) {\n\tconst matches = /^([^\\s:]+:)/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"]}
1
+ {"version":3,"names":["getProtocol","url","matches","exec"],"sources":["@wordpress/url/src/get-protocol.js"],"sourcesContent":["/**\n * Returns the protocol part of the URL.\n *\n * @param {string} url The full URL.\n *\n * @example\n * ```js\n * const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'\n * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'\n * ```\n *\n * @return {string|void} The protocol part of the URL.\n */\nexport function getProtocol( url ) {\n\tconst matches = /^([^\\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,GAAG,EAAG;EAClC,MAAMC,OAAO,GAAG,aAAa,CAACC,IAAI,CAAEF,GAAI,CAAC;EACzC,IAAKC,OAAO,EAAG;IACd,OAAOA,OAAO,CAAE,CAAC,CAAE;EACpB;AACD"}
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import { getQueryArgs } from './get-query-args';
5
+
5
6
  /**
6
7
  * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
7
8
  */
@@ -23,7 +24,6 @@ import { getQueryArgs } from './get-query-args';
23
24
  *
24
25
  * @return {QueryArgParsed|void} Query arg value.
25
26
  */
26
-
27
27
  export function getQueryArg(url, arg) {
28
28
  return getQueryArgs(url)[arg];
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-query-arg.js"],"names":["getQueryArgs","getQueryArg","url","arg"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,GAAtB,EAA2BC,GAA3B,EAAiC;AACvC,SAAOH,YAAY,CAAEE,GAAF,CAAZ,CAAqBC,GAArB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\n/**\n * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject\n */\n\n/**\n * @typedef {string|string[]|QueryArgObject} QueryArgParsed\n */\n\n/**\n * Returns a single query argument of the url\n *\n * @param {string} url URL.\n * @param {string} arg Query arg name.\n *\n * @example\n * ```js\n * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar\n * ```\n *\n * @return {QueryArgParsed|void} Query arg value.\n */\nexport function getQueryArg( url, arg ) {\n\treturn getQueryArgs( url )[ arg ];\n}\n"]}
1
+ {"version":3,"names":["getQueryArgs","getQueryArg","url","arg"],"sources":["@wordpress/url/src/get-query-arg.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\n/**\n * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject\n */\n\n/**\n * @typedef {string|string[]|QueryArgObject} QueryArgParsed\n */\n\n/**\n * Returns a single query argument of the url\n *\n * @param {string} url URL.\n * @param {string} arg Query arg name.\n *\n * @example\n * ```js\n * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar\n * ```\n *\n * @return {QueryArgParsed|void} Query arg value.\n */\nexport function getQueryArg( url, arg ) {\n\treturn getQueryArgs( url )[ arg ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAEC,GAAG,EAAEC,GAAG,EAAG;EACvC,OAAOH,YAAY,CAAEE,GAAI,CAAC,CAAEC,GAAG,CAAE;AAClC"}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { safeDecodeURIComponent } from './safe-decode-uri-component';
5
5
  import { getQueryString } from './get-query-string';
6
+
6
7
  /** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */
7
8
 
8
9
  /**
@@ -17,40 +18,40 @@ import { getQueryString } from './get-query-string';
17
18
  * @param {string[]} path Path segment at which to set value.
18
19
  * @param {*} value Value to set.
19
20
  */
20
-
21
21
  function setPath(object, path, value) {
22
22
  const length = path.length;
23
23
  const lastIndex = length - 1;
24
-
25
24
  for (let i = 0; i < length; i++) {
26
25
  let key = path[i];
27
-
28
26
  if (!key && Array.isArray(object)) {
29
27
  // If key is empty string and next value is array, derive key from
30
28
  // the current length of the array.
31
29
  key = object.length.toString();
32
30
  }
31
+ key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key;
33
32
 
34
- key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be
33
+ // If the next key in the path is numeric (or empty string), it will be
35
34
  // created as an array. Otherwise, it will be created as an object.
36
-
37
35
  const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
38
- object[key] = i === lastIndex ? // If at end of path, assign the intended value.
39
- value : // Otherwise, advance to the next object in the path, creating
36
+ object[key] = i === lastIndex ?
37
+ // If at end of path, assign the intended value.
38
+ value :
39
+ // Otherwise, advance to the next object in the path, creating
40
40
  // it if it does not yet exist.
41
41
  object[key] || (isNextKeyArrayIndex ? [] : {});
42
-
43
42
  if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
44
43
  // If we current key is non-numeric, but the next value is an
45
44
  // array, coerce the value to an object.
46
- object[key] = { ...object[key]
45
+ object[key] = {
46
+ ...object[key]
47
47
  };
48
- } // Update working reference object to the next in the path.
49
-
48
+ }
50
49
 
50
+ // Update working reference object to the next in the path.
51
51
  object = object[key];
52
52
  }
53
53
  }
54
+
54
55
  /**
55
56
  * Returns an object of query arguments of the given URL. If the given URL is
56
57
  * invalid or has no querystring, an empty object is returned.
@@ -65,23 +66,21 @@ function setPath(object, path, value) {
65
66
  *
66
67
  * @return {QueryArgs} Query args object.
67
68
  */
68
-
69
-
70
69
  export function getQueryArgs(url) {
71
- return (getQueryString(url) || '' // Normalize space encoding, accounting for PHP URL encoding
70
+ return (getQueryString(url) || ''
71
+ // Normalize space encoding, accounting for PHP URL encoding
72
72
  // corresponding to `application/x-www-form-urlencoded`.
73
73
  //
74
74
  // See: https://tools.ietf.org/html/rfc1866#section-8.2.1
75
75
  ).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => {
76
- const [key, value = ''] = keyValue.split('=') // Filtering avoids decoding as `undefined` for value, where
76
+ const [key, value = ''] = keyValue.split('=')
77
+ // Filtering avoids decoding as `undefined` for value, where
77
78
  // default is restored in destructuring assignment.
78
79
  .filter(Boolean).map(safeDecodeURIComponent);
79
-
80
80
  if (key) {
81
81
  const segments = key.replace(/\]/g, '').split('[');
82
82
  setPath(accumulator, segments, value);
83
83
  }
84
-
85
84
  return accumulator;
86
85
  }, Object.create(null));
87
86
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-query-args.js"],"names":["safeDecodeURIComponent","getQueryString","setPath","object","path","value","length","lastIndex","i","key","Array","isArray","toString","includes","toUpperCase","isNextKeyArrayIndex","isNaN","Number","getQueryArgs","url","replace","split","reduce","accumulator","keyValue","filter","Boolean","map","segments","Object","create"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAT,QAAuC,6BAAvC;AACA,SAASC,cAAT,QAA+B,oBAA/B;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,CAAkBC,MAAlB,EAA0BC,IAA1B,EAAgCC,KAAhC,EAAwC;AACvC,QAAMC,MAAM,GAAGF,IAAI,CAACE,MAApB;AACA,QAAMC,SAAS,GAAGD,MAAM,GAAG,CAA3B;;AACA,OAAM,IAAIE,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGF,MAArB,EAA6BE,CAAC,EAA9B,EAAmC;AAClC,QAAIC,GAAG,GAAGL,IAAI,CAAEI,CAAF,CAAd;;AAEA,QAAK,CAAEC,GAAF,IAASC,KAAK,CAACC,OAAN,CAAeR,MAAf,CAAd,EAAwC;AACvC;AACA;AACAM,MAAAA,GAAG,GAAGN,MAAM,CAACG,MAAP,CAAcM,QAAd,EAAN;AACA;;AAEDH,IAAAA,GAAG,GAAG,CAAE,WAAF,EAAe,aAAf,EAA8B,WAA9B,EAA4CI,QAA5C,CAAsDJ,GAAtD,IACHA,GAAG,CAACK,WAAJ,EADG,GAEHL,GAFH,CATkC,CAalC;AACA;;AACA,UAAMM,mBAAmB,GAAG,CAAEC,KAAK,CAAEC,MAAM,CAAEb,IAAI,CAAEI,CAAC,GAAG,CAAN,CAAN,CAAR,CAAnC;AAEAL,IAAAA,MAAM,CAAEM,GAAF,CAAN,GACCD,CAAC,KAAKD,SAAN,GACG;AACAF,IAAAA,KAFH,GAGG;AACA;AACAF,IAAAA,MAAM,CAAEM,GAAF,CAAN,KAAmBM,mBAAmB,GAAG,EAAH,GAAQ,EAA9C,CANJ;;AAQA,QAAKL,KAAK,CAACC,OAAN,CAAeR,MAAM,CAAEM,GAAF,CAArB,KAAkC,CAAEM,mBAAzC,EAA+D;AAC9D;AACA;AACAZ,MAAAA,MAAM,CAAEM,GAAF,CAAN,GAAgB,EAAE,GAAGN,MAAM,CAAEM,GAAF;AAAX,OAAhB;AACA,KA7BiC,CA+BlC;;;AACAN,IAAAA,MAAM,GAAGA,MAAM,CAAEM,GAAF,CAAf;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASS,YAAT,CAAuBC,GAAvB,EAA6B;AACnC,SACC,CAAElB,cAAc,CAAEkB,GAAF,CAAd,IAAyB,EAA3B,CACC;AACA;AACA;AACA;AAJD,IAKEC,OALF,CAKW,KALX,EAKkB,KALlB,EAMEC,KANF,CAMS,GANT,EAOEC,MAPF,CAOU,CAAEC,WAAF,EAAeC,QAAf,KAA6B;AACrC,UAAM,CAAEf,GAAF,EAAOJ,KAAK,GAAG,EAAf,IAAsBmB,QAAQ,CAClCH,KAD0B,CACnB,GADmB,EAE3B;AACA;AAH2B,KAI1BI,MAJ0B,CAIlBC,OAJkB,EAK1BC,GAL0B,CAKrB3B,sBALqB,CAA5B;;AAOA,QAAKS,GAAL,EAAW;AACV,YAAMmB,QAAQ,GAAGnB,GAAG,CAACW,OAAJ,CAAa,KAAb,EAAoB,EAApB,EAAyBC,KAAzB,CAAgC,GAAhC,CAAjB;AACAnB,MAAAA,OAAO,CAAEqB,WAAF,EAAeK,QAAf,EAAyBvB,KAAzB,CAAP;AACA;;AAED,WAAOkB,WAAP;AACA,GArBF,EAqBIM,MAAM,CAACC,MAAP,CAAe,IAAf,CArBJ,CADD;AAwBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { safeDecodeURIComponent } from './safe-decode-uri-component';\nimport { getQueryString } from './get-query-string';\n\n/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */\n\n/**\n * @typedef {Record<string,QueryArgParsed>} QueryArgs\n */\n\n/**\n * Sets a value in object deeply by a given array of path segments. Mutates the\n * object reference.\n *\n * @param {Record<string,*>} object Object in which to assign.\n * @param {string[]} path Path segment at which to set value.\n * @param {*} value Value to set.\n */\nfunction setPath( object, path, value ) {\n\tconst length = path.length;\n\tconst lastIndex = length - 1;\n\tfor ( let i = 0; i < length; i++ ) {\n\t\tlet key = path[ i ];\n\n\t\tif ( ! key && Array.isArray( object ) ) {\n\t\t\t// If key is empty string and next value is array, derive key from\n\t\t\t// the current length of the array.\n\t\t\tkey = object.length.toString();\n\t\t}\n\n\t\tkey = [ '__proto__', 'constructor', 'prototype' ].includes( key )\n\t\t\t? key.toUpperCase()\n\t\t\t: key;\n\n\t\t// If the next key in the path is numeric (or empty string), it will be\n\t\t// created as an array. Otherwise, it will be created as an object.\n\t\tconst isNextKeyArrayIndex = ! isNaN( Number( path[ i + 1 ] ) );\n\n\t\tobject[ key ] =\n\t\t\ti === lastIndex\n\t\t\t\t? // If at end of path, assign the intended value.\n\t\t\t\t value\n\t\t\t\t: // Otherwise, advance to the next object in the path, creating\n\t\t\t\t // it if it does not yet exist.\n\t\t\t\t object[ key ] || ( isNextKeyArrayIndex ? [] : {} );\n\n\t\tif ( Array.isArray( object[ key ] ) && ! isNextKeyArrayIndex ) {\n\t\t\t// If we current key is non-numeric, but the next value is an\n\t\t\t// array, coerce the value to an object.\n\t\t\tobject[ key ] = { ...object[ key ] };\n\t\t}\n\n\t\t// Update working reference object to the next in the path.\n\t\tobject = object[ key ];\n\t}\n}\n\n/**\n * Returns an object of query arguments of the given URL. If the given URL is\n * invalid or has no querystring, an empty object is returned.\n *\n * @param {string} url URL.\n *\n * @example\n * ```js\n * const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );\n * // { \"foo\": \"bar\", \"bar\": \"baz\" }\n * ```\n *\n * @return {QueryArgs} Query args object.\n */\nexport function getQueryArgs( url ) {\n\treturn (\n\t\t( getQueryString( url ) || '' )\n\t\t\t// Normalize space encoding, accounting for PHP URL encoding\n\t\t\t// corresponding to `application/x-www-form-urlencoded`.\n\t\t\t//\n\t\t\t// See: https://tools.ietf.org/html/rfc1866#section-8.2.1\n\t\t\t.replace( /\\+/g, '%20' )\n\t\t\t.split( '&' )\n\t\t\t.reduce( ( accumulator, keyValue ) => {\n\t\t\t\tconst [ key, value = '' ] = keyValue\n\t\t\t\t\t.split( '=' )\n\t\t\t\t\t// Filtering avoids decoding as `undefined` for value, where\n\t\t\t\t\t// default is restored in destructuring assignment.\n\t\t\t\t\t.filter( Boolean )\n\t\t\t\t\t.map( safeDecodeURIComponent );\n\n\t\t\t\tif ( key ) {\n\t\t\t\t\tconst segments = key.replace( /\\]/g, '' ).split( '[' );\n\t\t\t\t\tsetPath( accumulator, segments, value );\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t}, Object.create( null ) )\n\t);\n}\n"]}
1
+ {"version":3,"names":["safeDecodeURIComponent","getQueryString","setPath","object","path","value","length","lastIndex","i","key","Array","isArray","toString","includes","toUpperCase","isNextKeyArrayIndex","isNaN","Number","getQueryArgs","url","replace","split","reduce","accumulator","keyValue","filter","Boolean","map","segments","Object","create"],"sources":["@wordpress/url/src/get-query-args.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { safeDecodeURIComponent } from './safe-decode-uri-component';\nimport { getQueryString } from './get-query-string';\n\n/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */\n\n/**\n * @typedef {Record<string,QueryArgParsed>} QueryArgs\n */\n\n/**\n * Sets a value in object deeply by a given array of path segments. Mutates the\n * object reference.\n *\n * @param {Record<string,*>} object Object in which to assign.\n * @param {string[]} path Path segment at which to set value.\n * @param {*} value Value to set.\n */\nfunction setPath( object, path, value ) {\n\tconst length = path.length;\n\tconst lastIndex = length - 1;\n\tfor ( let i = 0; i < length; i++ ) {\n\t\tlet key = path[ i ];\n\n\t\tif ( ! key && Array.isArray( object ) ) {\n\t\t\t// If key is empty string and next value is array, derive key from\n\t\t\t// the current length of the array.\n\t\t\tkey = object.length.toString();\n\t\t}\n\n\t\tkey = [ '__proto__', 'constructor', 'prototype' ].includes( key )\n\t\t\t? key.toUpperCase()\n\t\t\t: key;\n\n\t\t// If the next key in the path is numeric (or empty string), it will be\n\t\t// created as an array. Otherwise, it will be created as an object.\n\t\tconst isNextKeyArrayIndex = ! isNaN( Number( path[ i + 1 ] ) );\n\n\t\tobject[ key ] =\n\t\t\ti === lastIndex\n\t\t\t\t? // If at end of path, assign the intended value.\n\t\t\t\t value\n\t\t\t\t: // Otherwise, advance to the next object in the path, creating\n\t\t\t\t // it if it does not yet exist.\n\t\t\t\t object[ key ] || ( isNextKeyArrayIndex ? [] : {} );\n\n\t\tif ( Array.isArray( object[ key ] ) && ! isNextKeyArrayIndex ) {\n\t\t\t// If we current key is non-numeric, but the next value is an\n\t\t\t// array, coerce the value to an object.\n\t\t\tobject[ key ] = { ...object[ key ] };\n\t\t}\n\n\t\t// Update working reference object to the next in the path.\n\t\tobject = object[ key ];\n\t}\n}\n\n/**\n * Returns an object of query arguments of the given URL. If the given URL is\n * invalid or has no querystring, an empty object is returned.\n *\n * @param {string} url URL.\n *\n * @example\n * ```js\n * const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );\n * // { \"foo\": \"bar\", \"bar\": \"baz\" }\n * ```\n *\n * @return {QueryArgs} Query args object.\n */\nexport function getQueryArgs( url ) {\n\treturn (\n\t\t( getQueryString( url ) || '' )\n\t\t\t// Normalize space encoding, accounting for PHP URL encoding\n\t\t\t// corresponding to `application/x-www-form-urlencoded`.\n\t\t\t//\n\t\t\t// See: https://tools.ietf.org/html/rfc1866#section-8.2.1\n\t\t\t.replace( /\\+/g, '%20' )\n\t\t\t.split( '&' )\n\t\t\t.reduce( ( accumulator, keyValue ) => {\n\t\t\t\tconst [ key, value = '' ] = keyValue\n\t\t\t\t\t.split( '=' )\n\t\t\t\t\t// Filtering avoids decoding as `undefined` for value, where\n\t\t\t\t\t// default is restored in destructuring assignment.\n\t\t\t\t\t.filter( Boolean )\n\t\t\t\t\t.map( safeDecodeURIComponent );\n\n\t\t\t\tif ( key ) {\n\t\t\t\t\tconst segments = key.replace( /\\]/g, '' ).split( '[' );\n\t\t\t\t\tsetPath( accumulator, segments, value );\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t}, Object.create( null ) )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,cAAc,QAAQ,oBAAoB;;AAEnD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,OAAOA,CAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAG;EACvC,MAAMC,MAAM,GAAGF,IAAI,CAACE,MAAM;EAC1B,MAAMC,SAAS,GAAGD,MAAM,GAAG,CAAC;EAC5B,KAAM,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,EAAEE,CAAC,EAAE,EAAG;IAClC,IAAIC,GAAG,GAAGL,IAAI,CAAEI,CAAC,CAAE;IAEnB,IAAK,CAAEC,GAAG,IAAIC,KAAK,CAACC,OAAO,CAAER,MAAO,CAAC,EAAG;MACvC;MACA;MACAM,GAAG,GAAGN,MAAM,CAACG,MAAM,CAACM,QAAQ,CAAC,CAAC;IAC/B;IAEAH,GAAG,GAAG,CAAE,WAAW,EAAE,aAAa,EAAE,WAAW,CAAE,CAACI,QAAQ,CAAEJ,GAAI,CAAC,GAC9DA,GAAG,CAACK,WAAW,CAAC,CAAC,GACjBL,GAAG;;IAEN;IACA;IACA,MAAMM,mBAAmB,GAAG,CAAEC,KAAK,CAAEC,MAAM,CAAEb,IAAI,CAAEI,CAAC,GAAG,CAAC,CAAG,CAAE,CAAC;IAE9DL,MAAM,CAAEM,GAAG,CAAE,GACZD,CAAC,KAAKD,SAAS;IACZ;IACAF,KAAK;IACL;IACA;IACAF,MAAM,CAAEM,GAAG,CAAE,KAAMM,mBAAmB,GAAG,EAAE,GAAG,CAAC,CAAC,CAAE;IAEtD,IAAKL,KAAK,CAACC,OAAO,CAAER,MAAM,CAAEM,GAAG,CAAG,CAAC,IAAI,CAAEM,mBAAmB,EAAG;MAC9D;MACA;MACAZ,MAAM,CAAEM,GAAG,CAAE,GAAG;QAAE,GAAGN,MAAM,CAAEM,GAAG;MAAG,CAAC;IACrC;;IAEA;IACAN,MAAM,GAAGA,MAAM,CAAEM,GAAG,CAAE;EACvB;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,YAAYA,CAAEC,GAAG,EAAG;EACnC,OACC,CAAElB,cAAc,CAAEkB,GAAI,CAAC,IAAI;EAC1B;EACA;EACA;EACA;EAAA,EACCC,OAAO,CAAE,KAAK,EAAE,KAAM,CAAC,CACvBC,KAAK,CAAE,GAAI,CAAC,CACZC,MAAM,CAAE,CAAEC,WAAW,EAAEC,QAAQ,KAAM;IACrC,MAAM,CAAEf,GAAG,EAAEJ,KAAK,GAAG,EAAE,CAAE,GAAGmB,QAAQ,CAClCH,KAAK,CAAE,GAAI;IACZ;IACA;IAAA,CACCI,MAAM,CAAEC,OAAQ,CAAC,CACjBC,GAAG,CAAE3B,sBAAuB,CAAC;IAE/B,IAAKS,GAAG,EAAG;MACV,MAAMmB,QAAQ,GAAGnB,GAAG,CAACW,OAAO,CAAE,KAAK,EAAE,EAAG,CAAC,CAACC,KAAK,CAAE,GAAI,CAAC;MACtDnB,OAAO,CAAEqB,WAAW,EAAEK,QAAQ,EAAEvB,KAAM,CAAC;IACxC;IAEA,OAAOkB,WAAW;EACnB,CAAC,EAAEM,MAAM,CAACC,MAAM,CAAE,IAAK,CAAE,CAAC;AAE7B"}
@@ -12,11 +12,9 @@
12
12
  */
13
13
  export function getQueryString(url) {
14
14
  let query;
15
-
16
15
  try {
17
16
  query = new URL(url, 'http://example.com').search.substring(1);
18
17
  } catch (error) {}
19
-
20
18
  if (query) {
21
19
  return query;
22
20
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/get-query-string.js"],"names":["getQueryString","url","query","URL","search","substring","error"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,cAAT,CAAyBC,GAAzB,EAA+B;AACrC,MAAIC,KAAJ;;AACA,MAAI;AACHA,IAAAA,KAAK,GAAG,IAAIC,GAAJ,CAASF,GAAT,EAAc,oBAAd,EAAqCG,MAArC,CAA4CC,SAA5C,CAAuD,CAAvD,CAAR;AACA,GAFD,CAEE,OAAQC,KAAR,EAAgB,CAAE;;AAEpB,MAAKJ,KAAL,EAAa;AACZ,WAAOA,KAAP;AACA;AACD","sourcesContent":["/**\n * Returns the query string part of the URL.\n *\n * @param {string} url The full URL.\n *\n * @example\n * ```js\n * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'\n * ```\n *\n * @return {string|void} The query string part of the URL.\n */\nexport function getQueryString( url ) {\n\tlet query;\n\ttry {\n\t\tquery = new URL( url, 'http://example.com' ).search.substring( 1 );\n\t} catch ( error ) {}\n\n\tif ( query ) {\n\t\treturn query;\n\t}\n}\n"]}
1
+ {"version":3,"names":["getQueryString","url","query","URL","search","substring","error"],"sources":["@wordpress/url/src/get-query-string.js"],"sourcesContent":["/**\n * Returns the query string part of the URL.\n *\n * @param {string} url The full URL.\n *\n * @example\n * ```js\n * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'\n * ```\n *\n * @return {string|void} The query string part of the URL.\n */\nexport function getQueryString( url ) {\n\tlet query;\n\ttry {\n\t\tquery = new URL( url, 'http://example.com' ).search.substring( 1 );\n\t} catch ( error ) {}\n\n\tif ( query ) {\n\t\treturn query;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,cAAcA,CAAEC,GAAG,EAAG;EACrC,IAAIC,KAAK;EACT,IAAI;IACHA,KAAK,GAAG,IAAIC,GAAG,CAAEF,GAAG,EAAE,oBAAqB,CAAC,CAACG,MAAM,CAACC,SAAS,CAAE,CAAE,CAAC;EACnE,CAAC,CAAC,OAAQC,KAAK,EAAG,CAAC;EAEnB,IAAKJ,KAAK,EAAG;IACZ,OAAOA,KAAK;EACb;AACD"}
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import { getQueryArg } from './get-query-arg';
5
+
5
6
  /**
6
7
  * Determines whether the URL contains a given query arg.
7
8
  *
@@ -15,7 +16,6 @@ import { getQueryArg } from './get-query-arg';
15
16
  *
16
17
  * @return {boolean} Whether or not the URL contains the query arg.
17
18
  */
18
-
19
19
  export function hasQueryArg(url, arg) {
20
20
  return getQueryArg(url, arg) !== undefined;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/has-query-arg.js"],"names":["getQueryArg","hasQueryArg","url","arg","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,GAAtB,EAA2BC,GAA3B,EAAiC;AACvC,SAAOH,WAAW,CAAEE,GAAF,EAAOC,GAAP,CAAX,KAA4BC,SAAnC;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArg } from './get-query-arg';\n\n/**\n * Determines whether the URL contains a given query arg.\n *\n * @param {string} url URL.\n * @param {string} arg Query arg name.\n *\n * @example\n * ```js\n * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true\n * ```\n *\n * @return {boolean} Whether or not the URL contains the query arg.\n */\nexport function hasQueryArg( url, arg ) {\n\treturn getQueryArg( url, arg ) !== undefined;\n}\n"]}
1
+ {"version":3,"names":["getQueryArg","hasQueryArg","url","arg","undefined"],"sources":["@wordpress/url/src/has-query-arg.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArg } from './get-query-arg';\n\n/**\n * Determines whether the URL contains a given query arg.\n *\n * @param {string} url URL.\n * @param {string} arg Query arg name.\n *\n * @example\n * ```js\n * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true\n * ```\n *\n * @return {boolean} Whether or not the URL contains the query arg.\n */\nexport function hasQueryArg( url, arg ) {\n\treturn getQueryArg( url, arg ) !== undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAEC,GAAG,EAAEC,GAAG,EAAG;EACvC,OAAOH,WAAW,CAAEE,GAAG,EAAEC,GAAI,CAAC,KAAKC,SAAS;AAC7C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/index.js"],"names":["isURL","isEmail","getProtocol","isValidProtocol","getAuthority","isValidAuthority","getPath","isValidPath","getQueryString","buildQueryString","isValidQueryString","getPathAndQueryString","getFragment","isValidFragment","addQueryArgs","getQueryArg","getQueryArgs","hasQueryArg","removeQueryArgs","prependHTTP","safeDecodeURI","safeDecodeURIComponent","filterURLForDisplay","cleanForSlug","getFilename","normalizePath","prependHTTPS"],"mappings":"AAAA,SAASA,KAAT,QAAsB,UAAtB;AACA,SAASC,OAAT,QAAwB,YAAxB;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,OAAT,QAAwB,YAAxB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,SAASC,kBAAT,QAAmC,yBAAnC;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,aAAT,QAA8B,mBAA9B;AACA,SAASC,sBAAT,QAAuC,6BAAvC;AACA,SAASC,mBAAT,QAAoC,0BAApC;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,aAAT,QAA8B,kBAA9B;AACA,SAASC,YAAT,QAA6B,iBAA7B","sourcesContent":["export { isURL } from './is-url';\nexport { isEmail } from './is-email';\nexport { getProtocol } from './get-protocol';\nexport { isValidProtocol } from './is-valid-protocol';\nexport { getAuthority } from './get-authority';\nexport { isValidAuthority } from './is-valid-authority';\nexport { getPath } from './get-path';\nexport { isValidPath } from './is-valid-path';\nexport { getQueryString } from './get-query-string';\nexport { buildQueryString } from './build-query-string';\nexport { isValidQueryString } from './is-valid-query-string';\nexport { getPathAndQueryString } from './get-path-and-query-string';\nexport { getFragment } from './get-fragment';\nexport { isValidFragment } from './is-valid-fragment';\nexport { addQueryArgs } from './add-query-args';\nexport { getQueryArg } from './get-query-arg';\nexport { getQueryArgs } from './get-query-args';\nexport { hasQueryArg } from './has-query-arg';\nexport { removeQueryArgs } from './remove-query-args';\nexport { prependHTTP } from './prepend-http';\nexport { safeDecodeURI } from './safe-decode-uri';\nexport { safeDecodeURIComponent } from './safe-decode-uri-component';\nexport { filterURLForDisplay } from './filter-url-for-display';\nexport { cleanForSlug } from './clean-for-slug';\nexport { getFilename } from './get-filename';\nexport { normalizePath } from './normalize-path';\nexport { prependHTTPS } from './prepend-https';\n"]}
1
+ {"version":3,"names":["isURL","isEmail","getProtocol","isValidProtocol","getAuthority","isValidAuthority","getPath","isValidPath","getQueryString","buildQueryString","isValidQueryString","getPathAndQueryString","getFragment","isValidFragment","addQueryArgs","getQueryArg","getQueryArgs","hasQueryArg","removeQueryArgs","prependHTTP","safeDecodeURI","safeDecodeURIComponent","filterURLForDisplay","cleanForSlug","getFilename","normalizePath","prependHTTPS"],"sources":["@wordpress/url/src/index.js"],"sourcesContent":["export { isURL } from './is-url';\nexport { isEmail } from './is-email';\nexport { getProtocol } from './get-protocol';\nexport { isValidProtocol } from './is-valid-protocol';\nexport { getAuthority } from './get-authority';\nexport { isValidAuthority } from './is-valid-authority';\nexport { getPath } from './get-path';\nexport { isValidPath } from './is-valid-path';\nexport { getQueryString } from './get-query-string';\nexport { buildQueryString } from './build-query-string';\nexport { isValidQueryString } from './is-valid-query-string';\nexport { getPathAndQueryString } from './get-path-and-query-string';\nexport { getFragment } from './get-fragment';\nexport { isValidFragment } from './is-valid-fragment';\nexport { addQueryArgs } from './add-query-args';\nexport { getQueryArg } from './get-query-arg';\nexport { getQueryArgs } from './get-query-args';\nexport { hasQueryArg } from './has-query-arg';\nexport { removeQueryArgs } from './remove-query-args';\nexport { prependHTTP } from './prepend-http';\nexport { safeDecodeURI } from './safe-decode-uri';\nexport { safeDecodeURIComponent } from './safe-decode-uri-component';\nexport { filterURLForDisplay } from './filter-url-for-display';\nexport { cleanForSlug } from './clean-for-slug';\nexport { getFilename } from './get-filename';\nexport { normalizePath } from './normalize-path';\nexport { prependHTTPS } from './prepend-https';\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,UAAU;AAChC,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,qBAAqB,QAAQ,6BAA6B;AACnE,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,YAAY,QAAQ,iBAAiB"}
@@ -1,4 +1,5 @@
1
1
  const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
2
+
2
3
  /**
3
4
  * Determines whether the given string looks like an email.
4
5
  *
@@ -11,7 +12,6 @@ const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}
11
12
  *
12
13
  * @return {boolean} Whether or not it looks like an email.
13
14
  */
14
-
15
15
  export function isEmail(email) {
16
16
  return EMAIL_REGEXP.test(email);
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-email.js"],"names":["EMAIL_REGEXP","isEmail","email","test"],"mappings":"AAAA,MAAMA,YAAY,GACjB,8DADD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,OAAT,CAAkBC,KAAlB,EAA0B;AAChC,SAAOF,YAAY,CAACG,IAAb,CAAmBD,KAAnB,CAAP;AACA","sourcesContent":["const EMAIL_REGEXP =\n\t/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\\.[a-z]{2,63}$/i;\n\n/**\n * Determines whether the given string looks like an email.\n *\n * @param {string} email The string to scrutinise.\n *\n * @example\n * ```js\n * const isEmail = isEmail( 'hello@wordpress.org' ); // true\n * ```\n *\n * @return {boolean} Whether or not it looks like an email.\n */\nexport function isEmail( email ) {\n\treturn EMAIL_REGEXP.test( email );\n}\n"]}
1
+ {"version":3,"names":["EMAIL_REGEXP","isEmail","email","test"],"sources":["@wordpress/url/src/is-email.js"],"sourcesContent":["const EMAIL_REGEXP =\n\t/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\\.[a-z]{2,63}$/i;\n\n/**\n * Determines whether the given string looks like an email.\n *\n * @param {string} email The string to scrutinise.\n *\n * @example\n * ```js\n * const isEmail = isEmail( 'hello@wordpress.org' ); // true\n * ```\n *\n * @return {boolean} Whether or not it looks like an email.\n */\nexport function isEmail( email ) {\n\treturn EMAIL_REGEXP.test( email );\n}\n"],"mappings":"AAAA,MAAMA,YAAY,GACjB,8DAA8D;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAAEC,KAAK,EAAG;EAChC,OAAOF,YAAY,CAACG,IAAI,CAAED,KAAM,CAAC;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-url.js"],"names":["isURL","url","URL"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,KAAT,CAAgBC,GAAhB,EAAsB;AAC5B;AACA;AACA,MAAI;AACH,QAAIC,GAAJ,CAASD,GAAT;AACA,WAAO,IAAP;AACA,GAHD,CAGE,MAAM;AACP,WAAO,KAAP;AACA;AACD","sourcesContent":["/**\n * Determines whether the given string looks like a URL.\n *\n * @param {string} url The string to scrutinise.\n *\n * @example\n * ```js\n * const isURL = isURL( 'https://wordpress.org' ); // true\n * ```\n *\n * @see https://url.spec.whatwg.org/\n * @see https://url.spec.whatwg.org/#valid-url-string\n *\n * @return {boolean} Whether or not it looks like a URL.\n */\nexport function isURL( url ) {\n\t// A URL can be considered value if the `URL` constructor is able to parse\n\t// it. The constructor throws an error for an invalid URL.\n\ttry {\n\t\tnew URL( url );\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"]}
1
+ {"version":3,"names":["isURL","url","URL"],"sources":["@wordpress/url/src/is-url.js"],"sourcesContent":["/**\n * Determines whether the given string looks like a URL.\n *\n * @param {string} url The string to scrutinise.\n *\n * @example\n * ```js\n * const isURL = isURL( 'https://wordpress.org' ); // true\n * ```\n *\n * @see https://url.spec.whatwg.org/\n * @see https://url.spec.whatwg.org/#valid-url-string\n *\n * @return {boolean} Whether or not it looks like a URL.\n */\nexport function isURL( url ) {\n\t// A URL can be considered value if the `URL` constructor is able to parse\n\t// it. The constructor throws an error for an invalid URL.\n\ttry {\n\t\tnew URL( url );\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,KAAKA,CAAEC,GAAG,EAAG;EAC5B;EACA;EACA,IAAI;IACH,IAAIC,GAAG,CAAED,GAAI,CAAC;IACd,OAAO,IAAI;EACZ,CAAC,CAAC,MAAM;IACP,OAAO,KAAK;EACb;AACD"}
@@ -15,7 +15,6 @@ export function isValidAuthority(authority) {
15
15
  if (!authority) {
16
16
  return false;
17
17
  }
18
-
19
18
  return /^[^\s#?]+$/.test(authority);
20
19
  }
21
20
  //# sourceMappingURL=is-valid-authority.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-valid-authority.js"],"names":["isValidAuthority","authority","test"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAT,CAA2BC,SAA3B,EAAuC;AAC7C,MAAK,CAAEA,SAAP,EAAmB;AAClB,WAAO,KAAP;AACA;;AACD,SAAO,aAAaC,IAAb,CAAmBD,SAAnB,CAAP;AACA","sourcesContent":["/**\n * Checks for invalid characters within the provided authority.\n *\n * @param {string} authority A string containing the URL authority.\n *\n * @example\n * ```js\n * const isValid = isValidAuthority( 'wordpress.org' ); // true\n * const isNotValid = isValidAuthority( 'wordpress#org' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid authority.\n */\nexport function isValidAuthority( authority ) {\n\tif ( ! authority ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?]+$/.test( authority );\n}\n"]}
1
+ {"version":3,"names":["isValidAuthority","authority","test"],"sources":["@wordpress/url/src/is-valid-authority.js"],"sourcesContent":["/**\n * Checks for invalid characters within the provided authority.\n *\n * @param {string} authority A string containing the URL authority.\n *\n * @example\n * ```js\n * const isValid = isValidAuthority( 'wordpress.org' ); // true\n * const isNotValid = isValidAuthority( 'wordpress#org' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid authority.\n */\nexport function isValidAuthority( authority ) {\n\tif ( ! authority ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?]+$/.test( authority );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAAEC,SAAS,EAAG;EAC7C,IAAK,CAAEA,SAAS,EAAG;IAClB,OAAO,KAAK;EACb;EACA,OAAO,YAAY,CAACC,IAAI,CAAED,SAAU,CAAC;AACtC"}
@@ -15,7 +15,6 @@ export function isValidFragment(fragment) {
15
15
  if (!fragment) {
16
16
  return false;
17
17
  }
18
-
19
18
  return /^#[^\s#?\/]*$/.test(fragment);
20
19
  }
21
20
  //# sourceMappingURL=is-valid-fragment.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-valid-fragment.js"],"names":["isValidFragment","fragment","test"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAT,CAA0BC,QAA1B,EAAqC;AAC3C,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AACD,SAAO,gBAAgBC,IAAhB,CAAsBD,QAAtB,CAAP;AACA","sourcesContent":["/**\n * Checks for invalid characters within the provided fragment.\n *\n * @param {string} fragment The url fragment.\n *\n * @example\n * ```js\n * const isValid = isValidFragment( '#valid-fragment' ); // true\n * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid fragment.\n */\nexport function isValidFragment( fragment ) {\n\tif ( ! fragment ) {\n\t\treturn false;\n\t}\n\treturn /^#[^\\s#?\\/]*$/.test( fragment );\n}\n"]}
1
+ {"version":3,"names":["isValidFragment","fragment","test"],"sources":["@wordpress/url/src/is-valid-fragment.js"],"sourcesContent":["/**\n * Checks for invalid characters within the provided fragment.\n *\n * @param {string} fragment The url fragment.\n *\n * @example\n * ```js\n * const isValid = isValidFragment( '#valid-fragment' ); // true\n * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid fragment.\n */\nexport function isValidFragment( fragment ) {\n\tif ( ! fragment ) {\n\t\treturn false;\n\t}\n\treturn /^#[^\\s#?\\/]*$/.test( fragment );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAAEC,QAAQ,EAAG;EAC3C,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA,OAAO,eAAe,CAACC,IAAI,CAAED,QAAS,CAAC;AACxC"}
@@ -15,7 +15,6 @@ export function isValidPath(path) {
15
15
  if (!path) {
16
16
  return false;
17
17
  }
18
-
19
18
  return /^[^\s#?]+$/.test(path);
20
19
  }
21
20
  //# sourceMappingURL=is-valid-path.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-valid-path.js"],"names":["isValidPath","path","test"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAT,CAAsBC,IAAtB,EAA6B;AACnC,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,KAAP;AACA;;AACD,SAAO,aAAaC,IAAb,CAAmBD,IAAnB,CAAP;AACA","sourcesContent":["/**\n * Checks for invalid characters within the provided path.\n *\n * @param {string} path The URL path.\n *\n * @example\n * ```js\n * const isValid = isValidPath( 'test/path/' ); // true\n * const isNotValid = isValidPath( '/invalid?test/path/' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid path\n */\nexport function isValidPath( path ) {\n\tif ( ! path ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?]+$/.test( path );\n}\n"]}
1
+ {"version":3,"names":["isValidPath","path","test"],"sources":["@wordpress/url/src/is-valid-path.js"],"sourcesContent":["/**\n * Checks for invalid characters within the provided path.\n *\n * @param {string} path The URL path.\n *\n * @example\n * ```js\n * const isValid = isValidPath( 'test/path/' ); // true\n * const isNotValid = isValidPath( '/invalid?test/path/' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid path\n */\nexport function isValidPath( path ) {\n\tif ( ! path ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?]+$/.test( path );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAAEC,IAAI,EAAG;EACnC,IAAK,CAAEA,IAAI,EAAG;IACb,OAAO,KAAK;EACb;EACA,OAAO,YAAY,CAACC,IAAI,CAAED,IAAK,CAAC;AACjC"}
@@ -15,7 +15,6 @@ export function isValidProtocol(protocol) {
15
15
  if (!protocol) {
16
16
  return false;
17
17
  }
18
-
19
18
  return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol);
20
19
  }
21
20
  //# sourceMappingURL=is-valid-protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-valid-protocol.js"],"names":["isValidProtocol","protocol","test"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAT,CAA0BC,QAA1B,EAAqC;AAC3C,MAAK,CAAEA,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AACD,SAAO,wBAAwBC,IAAxB,CAA8BD,QAA9B,CAAP;AACA","sourcesContent":["/**\n * Tests if a url protocol is valid.\n *\n * @param {string} protocol The url protocol.\n *\n * @example\n * ```js\n * const isValid = isValidProtocol( 'https:' ); // true\n * const isNotValid = isValidProtocol( 'https :' ); // false\n * ```\n *\n * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:).\n */\nexport function isValidProtocol( protocol ) {\n\tif ( ! protocol ) {\n\t\treturn false;\n\t}\n\treturn /^[a-z\\-.\\+]+[0-9]*:$/i.test( protocol );\n}\n"]}
1
+ {"version":3,"names":["isValidProtocol","protocol","test"],"sources":["@wordpress/url/src/is-valid-protocol.js"],"sourcesContent":["/**\n * Tests if a url protocol is valid.\n *\n * @param {string} protocol The url protocol.\n *\n * @example\n * ```js\n * const isValid = isValidProtocol( 'https:' ); // true\n * const isNotValid = isValidProtocol( 'https :' ); // false\n * ```\n *\n * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:).\n */\nexport function isValidProtocol( protocol ) {\n\tif ( ! protocol ) {\n\t\treturn false;\n\t}\n\treturn /^[a-z\\-.\\+]+[0-9]*:$/i.test( protocol );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAAEC,QAAQ,EAAG;EAC3C,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA,OAAO,uBAAuB,CAACC,IAAI,CAAED,QAAS,CAAC;AAChD"}
@@ -15,7 +15,6 @@ export function isValidQueryString(queryString) {
15
15
  if (!queryString) {
16
16
  return false;
17
17
  }
18
-
19
18
  return /^[^\s#?\/]+$/.test(queryString);
20
19
  }
21
20
  //# sourceMappingURL=is-valid-query-string.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/is-valid-query-string.js"],"names":["isValidQueryString","queryString","test"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,kBAAT,CAA6BC,WAA7B,EAA2C;AACjD,MAAK,CAAEA,WAAP,EAAqB;AACpB,WAAO,KAAP;AACA;;AACD,SAAO,eAAeC,IAAf,CAAqBD,WAArB,CAAP;AACA","sourcesContent":["/**\n * Checks for invalid characters within the provided query string.\n *\n * @param {string} queryString The query string.\n *\n * @example\n * ```js\n * const isValid = isValidQueryString( 'query=true&another=false' ); // true\n * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid query string.\n */\nexport function isValidQueryString( queryString ) {\n\tif ( ! queryString ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?\\/]+$/.test( queryString );\n}\n"]}
1
+ {"version":3,"names":["isValidQueryString","queryString","test"],"sources":["@wordpress/url/src/is-valid-query-string.js"],"sourcesContent":["/**\n * Checks for invalid characters within the provided query string.\n *\n * @param {string} queryString The query string.\n *\n * @example\n * ```js\n * const isValid = isValidQueryString( 'query=true&another=false' ); // true\n * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false\n * ```\n *\n * @return {boolean} True if the argument contains a valid query string.\n */\nexport function isValidQueryString( queryString ) {\n\tif ( ! queryString ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?\\/]+$/.test( queryString );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,kBAAkBA,CAAEC,WAAW,EAAG;EACjD,IAAK,CAAEA,WAAW,EAAG;IACpB,OAAO,KAAK;EACb;EACA,OAAO,cAAc,CAACC,IAAI,CAAED,WAAY,CAAC;AAC1C"}
@@ -11,19 +11,25 @@ export function normalizePath(path) {
11
11
  const splitted = path.split('?');
12
12
  const query = splitted[1];
13
13
  const base = splitted[0];
14
-
15
14
  if (!query) {
16
15
  return base;
17
- } // 'b=1%2C2&c=2&a=5'
18
-
16
+ }
19
17
 
20
- return base + '?' + query // [ 'b=1%2C2', 'c=2', 'a=5' ]
21
- .split('&') // [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]
22
- .map(entry => entry.split('=')) // [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]
23
- .map(pair => pair.map(decodeURIComponent)) // [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]
24
- .sort((a, b) => a[0].localeCompare(b[0])) // [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]
25
- .map(pair => pair.map(encodeURIComponent)) // [ 'a=5', 'b=1%2C2', 'c=2' ]
26
- .map(pair => pair.join('=')) // 'a=5&b=1%2C2&c=2'
18
+ // 'b=1%2C2&c=2&a=5'
19
+ return base + '?' + query
20
+ // [ 'b=1%2C2', 'c=2', 'a=5' ]
21
+ .split('&')
22
+ // [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]
23
+ .map(entry => entry.split('='))
24
+ // [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]
25
+ .map(pair => pair.map(decodeURIComponent))
26
+ // [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]
27
+ .sort((a, b) => a[0].localeCompare(b[0]))
28
+ // [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]
29
+ .map(pair => pair.map(encodeURIComponent))
30
+ // [ 'a=5', 'b=1%2C2', 'c=2' ]
31
+ .map(pair => pair.join('='))
32
+ // 'a=5&b=1%2C2&c=2'
27
33
  .join('&');
28
34
  }
29
35
  //# sourceMappingURL=normalize-path.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/normalize-path.js"],"names":["normalizePath","path","splitted","split","query","base","map","entry","pair","decodeURIComponent","sort","a","b","localeCompare","encodeURIComponent","join"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAT,CAAwBC,IAAxB,EAA+B;AACrC,QAAMC,QAAQ,GAAGD,IAAI,CAACE,KAAL,CAAY,GAAZ,CAAjB;AACA,QAAMC,KAAK,GAAGF,QAAQ,CAAE,CAAF,CAAtB;AACA,QAAMG,IAAI,GAAGH,QAAQ,CAAE,CAAF,CAArB;;AACA,MAAK,CAAEE,KAAP,EAAe;AACd,WAAOC,IAAP;AACA,GANoC,CAQrC;;;AACA,SACCA,IAAI,GACJ,GADA,GAEAD,KAAK,CACJ;AADI,GAEHD,KAFF,CAES,GAFT,EAGC;AAHD,GAIEG,GAJF,CAISC,KAAF,IAAaA,KAAK,CAACJ,KAAN,CAAa,GAAb,CAJpB,EAKC;AALD,GAMEG,GANF,CAMSE,IAAF,IAAYA,IAAI,CAACF,GAAL,CAAUG,kBAAV,CANnB,EAOC;AAPD,GAQEC,IARF,CAQQ,CAAEC,CAAF,EAAKC,CAAL,KAAYD,CAAC,CAAE,CAAF,CAAD,CAAOE,aAAP,CAAsBD,CAAC,CAAE,CAAF,CAAvB,CARpB,EASC;AATD,GAUEN,GAVF,CAUSE,IAAF,IAAYA,IAAI,CAACF,GAAL,CAAUQ,kBAAV,CAVnB,EAWC;AAXD,GAYER,GAZF,CAYSE,IAAF,IAAYA,IAAI,CAACO,IAAL,CAAW,GAAX,CAZnB,EAaC;AAbD,GAcEA,IAdF,CAcQ,GAdR,CAHD;AAmBA","sourcesContent":["/**\n * Given a path, returns a normalized path where equal query parameter values\n * will be treated as identical, regardless of order they appear in the original\n * text.\n *\n * @param {string} path Original path.\n *\n * @return {string} Normalized path.\n */\nexport function normalizePath( path ) {\n\tconst splitted = path.split( '?' );\n\tconst query = splitted[ 1 ];\n\tconst base = splitted[ 0 ];\n\tif ( ! query ) {\n\t\treturn base;\n\t}\n\n\t// 'b=1%2C2&c=2&a=5'\n\treturn (\n\t\tbase +\n\t\t'?' +\n\t\tquery\n\t\t\t// [ 'b=1%2C2', 'c=2', 'a=5' ]\n\t\t\t.split( '&' )\n\t\t\t// [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]\n\t\t\t.map( ( entry ) => entry.split( '=' ) )\n\t\t\t// [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]\n\t\t\t.map( ( pair ) => pair.map( decodeURIComponent ) )\n\t\t\t// [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]\n\t\t\t.sort( ( a, b ) => a[ 0 ].localeCompare( b[ 0 ] ) )\n\t\t\t// [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]\n\t\t\t.map( ( pair ) => pair.map( encodeURIComponent ) )\n\t\t\t// [ 'a=5', 'b=1%2C2', 'c=2' ]\n\t\t\t.map( ( pair ) => pair.join( '=' ) )\n\t\t\t// 'a=5&b=1%2C2&c=2'\n\t\t\t.join( '&' )\n\t);\n}\n"]}
1
+ {"version":3,"names":["normalizePath","path","splitted","split","query","base","map","entry","pair","decodeURIComponent","sort","a","b","localeCompare","encodeURIComponent","join"],"sources":["@wordpress/url/src/normalize-path.js"],"sourcesContent":["/**\n * Given a path, returns a normalized path where equal query parameter values\n * will be treated as identical, regardless of order they appear in the original\n * text.\n *\n * @param {string} path Original path.\n *\n * @return {string} Normalized path.\n */\nexport function normalizePath( path ) {\n\tconst splitted = path.split( '?' );\n\tconst query = splitted[ 1 ];\n\tconst base = splitted[ 0 ];\n\tif ( ! query ) {\n\t\treturn base;\n\t}\n\n\t// 'b=1%2C2&c=2&a=5'\n\treturn (\n\t\tbase +\n\t\t'?' +\n\t\tquery\n\t\t\t// [ 'b=1%2C2', 'c=2', 'a=5' ]\n\t\t\t.split( '&' )\n\t\t\t// [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]\n\t\t\t.map( ( entry ) => entry.split( '=' ) )\n\t\t\t// [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]\n\t\t\t.map( ( pair ) => pair.map( decodeURIComponent ) )\n\t\t\t// [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]\n\t\t\t.sort( ( a, b ) => a[ 0 ].localeCompare( b[ 0 ] ) )\n\t\t\t// [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]\n\t\t\t.map( ( pair ) => pair.map( encodeURIComponent ) )\n\t\t\t// [ 'a=5', 'b=1%2C2', 'c=2' ]\n\t\t\t.map( ( pair ) => pair.join( '=' ) )\n\t\t\t// 'a=5&b=1%2C2&c=2'\n\t\t\t.join( '&' )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAAEC,IAAI,EAAG;EACrC,MAAMC,QAAQ,GAAGD,IAAI,CAACE,KAAK,CAAE,GAAI,CAAC;EAClC,MAAMC,KAAK,GAAGF,QAAQ,CAAE,CAAC,CAAE;EAC3B,MAAMG,IAAI,GAAGH,QAAQ,CAAE,CAAC,CAAE;EAC1B,IAAK,CAAEE,KAAK,EAAG;IACd,OAAOC,IAAI;EACZ;;EAEA;EACA,OACCA,IAAI,GACJ,GAAG,GACHD;EACC;EAAA,CACCD,KAAK,CAAE,GAAI;EACZ;EAAA,CACCG,GAAG,CAAIC,KAAK,IAAMA,KAAK,CAACJ,KAAK,CAAE,GAAI,CAAE;EACtC;EAAA,CACCG,GAAG,CAAIE,IAAI,IAAMA,IAAI,CAACF,GAAG,CAAEG,kBAAmB,CAAE;EACjD;EAAA,CACCC,IAAI,CAAE,CAAEC,CAAC,EAAEC,CAAC,KAAMD,CAAC,CAAE,CAAC,CAAE,CAACE,aAAa,CAAED,CAAC,CAAE,CAAC,CAAG,CAAE;EAClD;EAAA,CACCN,GAAG,CAAIE,IAAI,IAAMA,IAAI,CAACF,GAAG,CAAEQ,kBAAmB,CAAE;EACjD;EAAA,CACCR,GAAG,CAAIE,IAAI,IAAMA,IAAI,CAACO,IAAI,CAAE,GAAI,CAAE;EACnC;EAAA,CACCA,IAAI,CAAE,GAAI,CAAC;AAEf"}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { isEmail } from './is-email';
5
5
  const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
6
+
6
7
  /**
7
8
  * Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
8
9
  *
@@ -15,18 +16,14 @@ const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
15
16
  *
16
17
  * @return {string} The updated URL.
17
18
  */
18
-
19
19
  export function prependHTTP(url) {
20
20
  if (!url) {
21
21
  return url;
22
22
  }
23
-
24
23
  url = url.trim();
25
-
26
24
  if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
27
25
  return 'http://' + url;
28
26
  }
29
-
30
27
  return url;
31
28
  }
32
29
  //# sourceMappingURL=prepend-http.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/url/src/prepend-http.js"],"names":["isEmail","USABLE_HREF_REGEXP","prependHTTP","url","trim","test"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,YAAxB;AAEA,MAAMC,kBAAkB,GAAG,0BAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,GAAtB,EAA4B;AAClC,MAAK,CAAEA,GAAP,EAAa;AACZ,WAAOA,GAAP;AACA;;AAEDA,EAAAA,GAAG,GAAGA,GAAG,CAACC,IAAJ,EAAN;;AACA,MAAK,CAAEH,kBAAkB,CAACI,IAAnB,CAAyBF,GAAzB,CAAF,IAAoC,CAAEH,OAAO,CAAEG,GAAF,CAAlD,EAA4D;AAC3D,WAAO,YAAYA,GAAnB;AACA;;AAED,SAAOA,GAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { isEmail } from './is-email';\n\nconst USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\\?|\\.|\\/)/i;\n\n/**\n * Prepends \"http://\" to a url, if it looks like something that is meant to be a TLD.\n *\n * @param {string} url The URL to test.\n *\n * @example\n * ```js\n * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org\n * ```\n *\n * @return {string} The updated URL.\n */\nexport function prependHTTP( url ) {\n\tif ( ! url ) {\n\t\treturn url;\n\t}\n\n\turl = url.trim();\n\tif ( ! USABLE_HREF_REGEXP.test( url ) && ! isEmail( url ) ) {\n\t\treturn 'http://' + url;\n\t}\n\n\treturn url;\n}\n"]}
1
+ {"version":3,"names":["isEmail","USABLE_HREF_REGEXP","prependHTTP","url","trim","test"],"sources":["@wordpress/url/src/prepend-http.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { isEmail } from './is-email';\n\nconst USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\\?|\\.|\\/)/i;\n\n/**\n * Prepends \"http://\" to a url, if it looks like something that is meant to be a TLD.\n *\n * @param {string} url The URL to test.\n *\n * @example\n * ```js\n * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org\n * ```\n *\n * @return {string} The updated URL.\n */\nexport function prependHTTP( url ) {\n\tif ( ! url ) {\n\t\treturn url;\n\t}\n\n\turl = url.trim();\n\tif ( ! USABLE_HREF_REGEXP.test( url ) && ! isEmail( url ) ) {\n\t\treturn 'http://' + url;\n\t}\n\n\treturn url;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,YAAY;AAEpC,MAAMC,kBAAkB,GAAG,0BAA0B;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAEC,GAAG,EAAG;EAClC,IAAK,CAAEA,GAAG,EAAG;IACZ,OAAOA,GAAG;EACX;EAEAA,GAAG,GAAGA,GAAG,CAACC,IAAI,CAAC,CAAC;EAChB,IAAK,CAAEH,kBAAkB,CAACI,IAAI,CAAEF,GAAI,CAAC,IAAI,CAAEH,OAAO,CAAEG,GAAI,CAAC,EAAG;IAC3D,OAAO,SAAS,GAAGA,GAAG;EACvB;EAEA,OAAOA,GAAG;AACX"}