@wordpress/url 4.26.1-next.719a03cbe.0 → 4.27.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 (207) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +12 -12
  3. package/build/add-query-args.js +4 -4
  4. package/build/add-query-args.js.map +1 -1
  5. package/build/build-query-string.js +3 -3
  6. package/build/build-query-string.js.map +1 -1
  7. package/build/clean-for-slug.js +2 -2
  8. package/build/clean-for-slug.js.map +1 -1
  9. package/build/filter-url-for-display.js +3 -3
  10. package/build/filter-url-for-display.js.map +1 -1
  11. package/build/get-authority.js +2 -2
  12. package/build/get-authority.js.map +1 -1
  13. package/build/get-filename.js +2 -2
  14. package/build/get-filename.js.map +1 -1
  15. package/build/get-fragment.js +2 -2
  16. package/build/get-fragment.js.map +1 -1
  17. package/build/get-path-and-query-string.js +2 -2
  18. package/build/get-path-and-query-string.js.map +1 -1
  19. package/build/get-path.js +2 -2
  20. package/build/get-path.js.map +1 -1
  21. package/build/get-protocol.js +2 -2
  22. package/build/get-protocol.js.map +1 -1
  23. package/build/get-query-arg.js +3 -11
  24. package/build/get-query-arg.js.map +1 -1
  25. package/build/get-query-args.js +5 -11
  26. package/build/get-query-args.js.map +1 -1
  27. package/build/get-query-string.js +2 -2
  28. package/build/get-query-string.js.map +1 -1
  29. package/build/has-query-arg.js +3 -3
  30. package/build/has-query-arg.js.map +1 -1
  31. package/build/index.js.map +1 -1
  32. package/build/is-email.js +2 -2
  33. package/build/is-email.js.map +1 -1
  34. package/build/is-phone-number.js +2 -2
  35. package/build/is-phone-number.js.map +1 -1
  36. package/build/is-url.js +2 -2
  37. package/build/is-url.js.map +1 -1
  38. package/build/is-valid-authority.js +2 -2
  39. package/build/is-valid-authority.js.map +1 -1
  40. package/build/is-valid-fragment.js +2 -2
  41. package/build/is-valid-fragment.js.map +1 -1
  42. package/build/is-valid-path.js +2 -2
  43. package/build/is-valid-path.js.map +1 -1
  44. package/build/is-valid-protocol.js +2 -2
  45. package/build/is-valid-protocol.js.map +1 -1
  46. package/build/is-valid-query-string.js +2 -2
  47. package/build/is-valid-query-string.js.map +1 -1
  48. package/build/normalize-path.js +2 -2
  49. package/build/normalize-path.js.map +1 -1
  50. package/build/prepend-http.js +2 -2
  51. package/build/prepend-http.js.map +1 -1
  52. package/build/prepend-https.js +2 -2
  53. package/build/prepend-https.js.map +1 -1
  54. package/build/remove-query-args.js +3 -3
  55. package/build/remove-query-args.js.map +1 -1
  56. package/build/safe-decode-uri-component.js +2 -2
  57. package/build/safe-decode-uri-component.js.map +1 -1
  58. package/build/safe-decode-uri.js +2 -2
  59. package/build/safe-decode-uri.js.map +1 -1
  60. package/build-module/add-query-args.js +4 -4
  61. package/build-module/add-query-args.js.map +1 -1
  62. package/build-module/build-query-string.js +3 -3
  63. package/build-module/build-query-string.js.map +1 -1
  64. package/build-module/clean-for-slug.js +2 -2
  65. package/build-module/clean-for-slug.js.map +1 -1
  66. package/build-module/filter-url-for-display.js +3 -3
  67. package/build-module/filter-url-for-display.js.map +1 -1
  68. package/build-module/get-authority.js +2 -2
  69. package/build-module/get-authority.js.map +1 -1
  70. package/build-module/get-filename.js +2 -2
  71. package/build-module/get-filename.js.map +1 -1
  72. package/build-module/get-fragment.js +2 -2
  73. package/build-module/get-fragment.js.map +1 -1
  74. package/build-module/get-path-and-query-string.js +2 -2
  75. package/build-module/get-path-and-query-string.js.map +1 -1
  76. package/build-module/get-path.js +2 -2
  77. package/build-module/get-path.js.map +1 -1
  78. package/build-module/get-protocol.js +2 -2
  79. package/build-module/get-protocol.js.map +1 -1
  80. package/build-module/get-query-arg.js +3 -12
  81. package/build-module/get-query-arg.js.map +1 -1
  82. package/build-module/get-query-args.js +5 -12
  83. package/build-module/get-query-args.js.map +1 -1
  84. package/build-module/get-query-string.js +2 -2
  85. package/build-module/get-query-string.js.map +1 -1
  86. package/build-module/has-query-arg.js +3 -3
  87. package/build-module/has-query-arg.js.map +1 -1
  88. package/build-module/index.js.map +1 -1
  89. package/build-module/is-email.js +2 -2
  90. package/build-module/is-email.js.map +1 -1
  91. package/build-module/is-phone-number.js +2 -2
  92. package/build-module/is-phone-number.js.map +1 -1
  93. package/build-module/is-url.js +2 -2
  94. package/build-module/is-url.js.map +1 -1
  95. package/build-module/is-valid-authority.js +2 -2
  96. package/build-module/is-valid-authority.js.map +1 -1
  97. package/build-module/is-valid-fragment.js +2 -2
  98. package/build-module/is-valid-fragment.js.map +1 -1
  99. package/build-module/is-valid-path.js +2 -2
  100. package/build-module/is-valid-path.js.map +1 -1
  101. package/build-module/is-valid-protocol.js +2 -2
  102. package/build-module/is-valid-protocol.js.map +1 -1
  103. package/build-module/is-valid-query-string.js +2 -2
  104. package/build-module/is-valid-query-string.js.map +1 -1
  105. package/build-module/normalize-path.js +2 -2
  106. package/build-module/normalize-path.js.map +1 -1
  107. package/build-module/prepend-http.js +2 -2
  108. package/build-module/prepend-http.js.map +1 -1
  109. package/build-module/prepend-https.js +2 -2
  110. package/build-module/prepend-https.js.map +1 -1
  111. package/build-module/remove-query-args.js +3 -3
  112. package/build-module/remove-query-args.js.map +1 -1
  113. package/build-module/safe-decode-uri-component.js +2 -2
  114. package/build-module/safe-decode-uri-component.js.map +1 -1
  115. package/build-module/safe-decode-uri.js +2 -2
  116. package/build-module/safe-decode-uri.js.map +1 -1
  117. package/build-types/add-query-args.d.ts +5 -5
  118. package/build-types/add-query-args.d.ts.map +1 -1
  119. package/build-types/build-query-string.d.ts +3 -3
  120. package/build-types/build-query-string.d.ts.map +1 -1
  121. package/build-types/clean-for-slug.d.ts +3 -3
  122. package/build-types/clean-for-slug.d.ts.map +1 -1
  123. package/build-types/filter-url-for-display.d.ts +4 -4
  124. package/build-types/filter-url-for-display.d.ts.map +1 -1
  125. package/build-types/get-authority.d.ts +3 -3
  126. package/build-types/get-authority.d.ts.map +1 -1
  127. package/build-types/get-filename.d.ts +3 -3
  128. package/build-types/get-filename.d.ts.map +1 -1
  129. package/build-types/get-fragment.d.ts +3 -3
  130. package/build-types/get-fragment.d.ts.map +1 -1
  131. package/build-types/get-path-and-query-string.d.ts +3 -3
  132. package/build-types/get-path-and-query-string.d.ts.map +1 -1
  133. package/build-types/get-path.d.ts +3 -3
  134. package/build-types/get-path.d.ts.map +1 -1
  135. package/build-types/get-protocol.d.ts +3 -3
  136. package/build-types/get-protocol.d.ts.map +1 -1
  137. package/build-types/get-query-arg.d.ts +8 -14
  138. package/build-types/get-query-arg.d.ts.map +1 -1
  139. package/build-types/get-query-args.d.ts +6 -5
  140. package/build-types/get-query-args.d.ts.map +1 -1
  141. package/build-types/get-query-string.d.ts +3 -3
  142. package/build-types/get-query-string.d.ts.map +1 -1
  143. package/build-types/has-query-arg.d.ts +4 -4
  144. package/build-types/has-query-arg.d.ts.map +1 -1
  145. package/build-types/index.d.ts +28 -28
  146. package/build-types/index.d.ts.map +1 -1
  147. package/build-types/is-email.d.ts +3 -3
  148. package/build-types/is-email.d.ts.map +1 -1
  149. package/build-types/is-phone-number.d.ts +3 -3
  150. package/build-types/is-phone-number.d.ts.map +1 -1
  151. package/build-types/is-url.d.ts +3 -3
  152. package/build-types/is-url.d.ts.map +1 -1
  153. package/build-types/is-valid-authority.d.ts +3 -3
  154. package/build-types/is-valid-authority.d.ts.map +1 -1
  155. package/build-types/is-valid-fragment.d.ts +3 -3
  156. package/build-types/is-valid-fragment.d.ts.map +1 -1
  157. package/build-types/is-valid-path.d.ts +3 -3
  158. package/build-types/is-valid-path.d.ts.map +1 -1
  159. package/build-types/is-valid-protocol.d.ts +3 -3
  160. package/build-types/is-valid-protocol.d.ts.map +1 -1
  161. package/build-types/is-valid-query-string.d.ts +3 -3
  162. package/build-types/is-valid-query-string.d.ts.map +1 -1
  163. package/build-types/normalize-path.d.ts +3 -3
  164. package/build-types/normalize-path.d.ts.map +1 -1
  165. package/build-types/prepend-http.d.ts +3 -3
  166. package/build-types/prepend-http.d.ts.map +1 -1
  167. package/build-types/prepend-https.d.ts +3 -3
  168. package/build-types/prepend-https.d.ts.map +1 -1
  169. package/build-types/remove-query-args.d.ts +4 -4
  170. package/build-types/remove-query-args.d.ts.map +1 -1
  171. package/build-types/safe-decode-uri-component.d.ts +3 -3
  172. package/build-types/safe-decode-uri-component.d.ts.map +1 -1
  173. package/build-types/safe-decode-uri.d.ts +3 -3
  174. package/build-types/safe-decode-uri.d.ts.map +1 -1
  175. package/package.json +2 -2
  176. package/src/{add-query-args.js → add-query-args.ts} +8 -5
  177. package/src/{build-query-string.js → build-query-string.ts} +7 -6
  178. package/src/{clean-for-slug.js → clean-for-slug.ts} +3 -3
  179. package/src/{filter-url-for-display.js → filter-url-for-display.ts} +7 -4
  180. package/src/{get-authority.js → get-authority.ts} +3 -3
  181. package/src/{get-filename.js → get-filename.ts} +3 -3
  182. package/src/{get-fragment.js → get-fragment.ts} +3 -3
  183. package/src/{get-path-and-query-string.js → get-path-and-query-string.ts} +3 -3
  184. package/src/{get-path.js → get-path.ts} +3 -3
  185. package/src/{get-protocol.js → get-protocol.ts} +3 -3
  186. package/src/get-query-arg.ts +30 -0
  187. package/src/{get-query-args.js → get-query-args.ts} +9 -12
  188. package/src/{get-query-string.js → get-query-string.ts} +3 -3
  189. package/src/{has-query-arg.js → has-query-arg.ts} +4 -4
  190. package/src/{is-email.js → is-email.ts} +3 -3
  191. package/src/{is-phone-number.js → is-phone-number.ts} +3 -3
  192. package/src/{is-url.js → is-url.ts} +3 -3
  193. package/src/{is-valid-authority.js → is-valid-authority.ts} +3 -3
  194. package/src/{is-valid-fragment.js → is-valid-fragment.ts} +3 -3
  195. package/src/{is-valid-path.js → is-valid-path.ts} +3 -3
  196. package/src/{is-valid-protocol.js → is-valid-protocol.ts} +3 -3
  197. package/src/{is-valid-query-string.js → is-valid-query-string.ts} +3 -3
  198. package/src/{normalize-path.js → normalize-path.ts} +3 -3
  199. package/src/{prepend-http.js → prepend-http.ts} +3 -3
  200. package/src/{prepend-https.js → prepend-https.ts} +3 -3
  201. package/src/{remove-query-args.js → remove-query-args.ts} +4 -4
  202. package/src/{safe-decode-uri-component.js → safe-decode-uri-component.ts} +3 -3
  203. package/src/{safe-decode-uri.js → safe-decode-uri.ts} +3 -3
  204. package/src/test/index.js +2 -2
  205. package/tsconfig.tsbuildinfo +1 -1
  206. package/src/get-query-arg.js +0 -29
  207. /package/src/{index.js → index.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Checks for invalid characters within the provided fragment.
3
3
  *
4
- * @param {string} fragment The url fragment.
4
+ * @param fragment The url fragment.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,7 +9,7 @@
9
9
  * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
10
10
  * ```
11
11
  *
12
- * @return {boolean} True if the argument contains a valid fragment.
12
+ * @return True if the argument contains a valid fragment.
13
13
  */
14
- export function isValidFragment(fragment: string): boolean;
14
+ export declare function isValidFragment(fragment: string): boolean;
15
15
  //# sourceMappingURL=is-valid-fragment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-fragment.d.ts","sourceRoot":"","sources":["../src/is-valid-fragment.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,0CAVW,MAAM,GAQL,OAAO,CAOlB"}
1
+ {"version":3,"file":"is-valid-fragment.d.ts","sourceRoot":"","sources":["../src/is-valid-fragment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAK3D"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Checks for invalid characters within the provided path.
3
3
  *
4
- * @param {string} path The URL path.
4
+ * @param path The URL path.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,7 +9,7 @@
9
9
  * const isNotValid = isValidPath( '/invalid?test/path/' ); // false
10
10
  * ```
11
11
  *
12
- * @return {boolean} True if the argument contains a valid path
12
+ * @return True if the argument contains a valid path
13
13
  */
14
- export function isValidPath(path: string): boolean;
14
+ export declare function isValidPath(path: string): boolean;
15
15
  //# sourceMappingURL=is-valid-path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-path.d.ts","sourceRoot":"","sources":["../src/is-valid-path.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,kCAVW,MAAM,GAQL,OAAO,CAOlB"}
1
+ {"version":3,"file":"is-valid-path.d.ts","sourceRoot":"","sources":["../src/is-valid-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAKnD"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Tests if a url protocol is valid.
3
3
  *
4
- * @param {string} protocol The url protocol.
4
+ * @param protocol The url protocol.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,7 +9,7 @@
9
9
  * const isNotValid = isValidProtocol( 'https :' ); // false
10
10
  * ```
11
11
  *
12
- * @return {boolean} True if the argument is a valid protocol (e.g. http:, tel:).
12
+ * @return True if the argument is a valid protocol (e.g. http:, tel:).
13
13
  */
14
- export function isValidProtocol(protocol: string): boolean;
14
+ export declare function isValidProtocol(protocol: string): boolean;
15
15
  //# sourceMappingURL=is-valid-protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-protocol.d.ts","sourceRoot":"","sources":["../src/is-valid-protocol.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,0CAVW,MAAM,GAQL,OAAO,CAOlB"}
1
+ {"version":3,"file":"is-valid-protocol.d.ts","sourceRoot":"","sources":["../src/is-valid-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAK3D"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Checks for invalid characters within the provided query string.
3
3
  *
4
- * @param {string} queryString The query string.
4
+ * @param queryString The query string.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,7 +9,7 @@
9
9
  * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false
10
10
  * ```
11
11
  *
12
- * @return {boolean} True if the argument contains a valid query string.
12
+ * @return True if the argument contains a valid query string.
13
13
  */
14
- export function isValidQueryString(queryString: string): boolean;
14
+ export declare function isValidQueryString(queryString: string): boolean;
15
15
  //# sourceMappingURL=is-valid-query-string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-query-string.d.ts","sourceRoot":"","sources":["../src/is-valid-query-string.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,gDAVW,MAAM,GAQL,OAAO,CAOlB"}
1
+ {"version":3,"file":"is-valid-query-string.d.ts","sourceRoot":"","sources":["../src/is-valid-query-string.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAE,WAAW,EAAE,MAAM,GAAI,OAAO,CAKjE"}
@@ -3,9 +3,9 @@
3
3
  * will be treated as identical, regardless of order they appear in the original
4
4
  * text.
5
5
  *
6
- * @param {string} path Original path.
6
+ * @param path Original path.
7
7
  *
8
- * @return {string} Normalized path.
8
+ * @return Normalized path.
9
9
  */
10
- export function normalizePath(path: string): string;
10
+ export declare function normalizePath(path: string): string;
11
11
  //# sourceMappingURL=normalize-path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-path.d.ts","sourceRoot":"","sources":["../src/normalize-path.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,oCAJW,MAAM,GAEL,MAAM,CA8BjB"}
1
+ {"version":3,"file":"normalize-path.d.ts","sourceRoot":"","sources":["../src/normalize-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CA4BpD"}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
3
3
  *
4
- * @param {string} url The URL to test.
4
+ * @param url The URL to test.
5
5
  *
6
6
  * @example
7
7
  * ```js
8
8
  * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org
9
9
  * ```
10
10
  *
11
- * @return {string} The updated URL.
11
+ * @return The updated URL.
12
12
  */
13
- export function prependHTTP(url: string): string;
13
+ export declare function prependHTTP(url: string): string;
14
14
  //# sourceMappingURL=prepend-http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepend-http.d.ts","sourceRoot":"","sources":["../src/prepend-http.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,iCATW,MAAM,GAOL,MAAM,CAajB"}
1
+ {"version":3,"file":"prepend-http.d.ts","sourceRoot":"","sources":["../src/prepend-http.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAWjD"}
@@ -3,14 +3,14 @@
3
3
  *
4
4
  * Note: this will not replace "http://" with "https://".
5
5
  *
6
- * @param {string} url The URL to test.
6
+ * @param url The URL to test.
7
7
  *
8
8
  * @example
9
9
  * ```js
10
10
  * const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org
11
11
  * ```
12
12
  *
13
- * @return {string} The updated URL.
13
+ * @return The updated URL.
14
14
  */
15
- export function prependHTTPS(url: string): string;
15
+ export declare function prependHTTPS(url: string): string;
16
16
  //# sourceMappingURL=prepend-https.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepend-https.d.ts","sourceRoot":"","sources":["../src/prepend-https.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,kCATW,MAAM,GAOL,MAAM,CAejB"}
1
+ {"version":3,"file":"prepend-https.d.ts","sourceRoot":"","sources":["../src/prepend-https.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAalD"}
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * Removes arguments from the query string of the url
3
3
  *
4
- * @param {string} url URL.
5
- * @param {...string} args Query Args.
4
+ * @param url URL.
5
+ * @param args Query Args.
6
6
  *
7
7
  * @example
8
8
  * ```js
9
9
  * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
10
10
  * ```
11
11
  *
12
- * @return {string} Updated URL.
12
+ * @return Updated URL.
13
13
  */
14
- export function removeQueryArgs(url: string, ...args: string[]): string;
14
+ export declare function removeQueryArgs(url: string, ...args: string[]): string;
15
15
  //# sourceMappingURL=remove-query-args.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remove-query-args.d.ts","sourceRoot":"","sources":["../src/remove-query-args.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,qCAVW,MAAM,WACH,MAAM,EAAA,GAOR,MAAM,CAiBjB"}
1
+ {"version":3,"file":"remove-query-args.d.ts","sourceRoot":"","sources":["../src/remove-query-args.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAI,MAAM,CAexE"}
@@ -2,9 +2,9 @@
2
2
  * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
3
3
  * `decodeURIComponent` throws an error.
4
4
  *
5
- * @param {string} uriComponent URI component to decode.
5
+ * @param uriComponent URI component to decode.
6
6
  *
7
- * @return {string} Decoded URI component if possible.
7
+ * @return Decoded URI component if possible.
8
8
  */
9
- export function safeDecodeURIComponent(uriComponent: string): string;
9
+ export declare function safeDecodeURIComponent(uriComponent: string): string;
10
10
  //# sourceMappingURL=safe-decode-uri-component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe-decode-uri-component.d.ts","sourceRoot":"","sources":["../src/safe-decode-uri-component.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qDAJW,MAAM,GAEL,MAAM,CAQjB"}
1
+ {"version":3,"file":"safe-decode-uri-component.d.ts","sourceRoot":"","sources":["../src/safe-decode-uri-component.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAE,YAAY,EAAE,MAAM,GAAI,MAAM,CAMrE"}
@@ -2,14 +2,14 @@
2
2
  * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
3
3
  * `decodeURI` throws an error.
4
4
  *
5
- * @param {string} uri URI to decode.
5
+ * @param uri URI to decode.
6
6
  *
7
7
  * @example
8
8
  * ```js
9
9
  * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
10
10
  * ```
11
11
  *
12
- * @return {string} Decoded URI if possible.
12
+ * @return Decoded URI if possible.
13
13
  */
14
- export function safeDecodeURI(uri: string): string;
14
+ export declare function safeDecodeURI(uri: string): string;
15
15
  //# sourceMappingURL=safe-decode-uri.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe-decode-uri.d.ts","sourceRoot":"","sources":["../src/safe-decode-uri.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,mCATW,MAAM,GAOL,MAAM,CAQjB"}
1
+ {"version":3,"file":"safe-decode-uri.d.ts","sourceRoot":"","sources":["../src/safe-decode-uri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAMnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/url",
3
- "version": "4.26.1-next.719a03cbe.0",
3
+ "version": "4.27.0",
4
4
  "description": "WordPress URL utilities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "5e146e949c2765411a8310bcc2641a88d036a6d9"
38
+ "gitHead": "abe06a6f2aef8d03c30ea9d5b3e133f041e523b1"
39
39
  }
@@ -10,18 +10,21 @@ import { getFragment } from './get-fragment';
10
10
  * includes query arguments, the arguments are merged with (and take precedent
11
11
  * over) the existing set.
12
12
  *
13
- * @param {string} [url=''] URL to which arguments should be appended. If omitted,
14
- * only the resulting querystring is returned.
15
- * @param {Object} [args] Query arguments to apply to URL.
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
16
  *
17
17
  * @example
18
18
  * ```js
19
19
  * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
20
20
  * ```
21
21
  *
22
- * @return {string} URL with arguments applied.
22
+ * @return URL with arguments applied.
23
23
  */
24
- export function addQueryArgs( url = '', args ) {
24
+ export function addQueryArgs(
25
+ url: string = '',
26
+ args?: Record< string, unknown >
27
+ ): string {
25
28
  // If no arguments are to be appended, return original URL.
26
29
  if ( ! args || ! Object.keys( args ).length ) {
27
30
  return url;
@@ -18,14 +18,14 @@
18
18
  * // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
19
19
  * ```
20
20
  *
21
- * @param {Record<string,*>} data Data to encode.
21
+ * @param data Data to encode.
22
22
  *
23
- * @return {string} Query string.
23
+ * @return Query string.
24
24
  */
25
- export function buildQueryString( data ) {
25
+ export function buildQueryString( data: Record< string, unknown > ): string {
26
26
  let string = '';
27
27
 
28
- const stack = Object.entries( data );
28
+ const stack: Array< [ string, unknown ] > = Object.entries( data );
29
29
 
30
30
  let pair;
31
31
  while ( ( pair = stack.shift() ) ) {
@@ -39,7 +39,7 @@ export function buildQueryString( data ) {
39
39
  // Push array or object values onto the stack as composed of their
40
40
  // original key and nested index or key, retaining order by a
41
41
  // combination of Array#reverse and Array#unshift onto the stack.
42
- const valuePairs = Object.entries( value ).reverse();
42
+ const valuePairs = Object.entries( value as object ).reverse();
43
43
  for ( const [ member, memberValue ] of valuePairs ) {
44
44
  stack.unshift( [ `${ key }[${ member }]`, memberValue ] );
45
45
  }
@@ -50,7 +50,8 @@ export function buildQueryString( data ) {
50
50
  }
51
51
 
52
52
  string +=
53
- '&' + [ key, value ].map( encodeURIComponent ).join( '=' );
53
+ '&' +
54
+ [ key, String( value ) ].map( encodeURIComponent ).join( '=' );
54
55
  }
55
56
  }
56
57
 
@@ -15,11 +15,11 @@ import removeAccents from 'remove-accents';
15
15
  * except hyphens. Converts remaining string to lowercase. It does not account
16
16
  * for octets, HTML entities, or other encoded characters.
17
17
  *
18
- * @param {string} string Title or slug to be processed.
18
+ * @param string Title or slug to be processed.
19
19
  *
20
- * @return {string} Processed string.
20
+ * @return Processed string.
21
21
  */
22
- export function cleanForSlug( string ) {
22
+ export function cleanForSlug( string: string ): string {
23
23
  if ( ! string ) {
24
24
  return '';
25
25
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Returns a URL for display.
3
3
  *
4
- * @param {string} url Original URL.
5
- * @param {number|null} maxLength URL length.
4
+ * @param url Original URL.
5
+ * @param maxLength URL length.
6
6
  *
7
7
  * @example
8
8
  * ```js
@@ -10,9 +10,12 @@
10
10
  * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
11
11
  * ```
12
12
  *
13
- * @return {string} Displayed URL.
13
+ * @return Displayed URL.
14
14
  */
15
- export function filterURLForDisplay( url, maxLength = null ) {
15
+ export function filterURLForDisplay(
16
+ url: string,
17
+ maxLength: number | null = null
18
+ ): string {
16
19
  if ( ! url ) {
17
20
  return '';
18
21
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the authority part of the URL.
3
3
  *
4
- * @param {string} url The full URL.
4
+ * @param url The full URL.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,9 +9,9 @@
9
9
  * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
10
10
  * ```
11
11
  *
12
- * @return {string|void} The authority part of the URL.
12
+ * @return The authority part of the URL.
13
13
  */
14
- export function getAuthority( url ) {
14
+ export function getAuthority( url: string ): string | void {
15
15
  const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(
16
16
  url
17
17
  );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the filename part of the URL.
3
3
  *
4
- * @param {string} url The full URL.
4
+ * @param url The full URL.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,9 +9,9 @@
9
9
  * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
10
10
  * ```
11
11
  *
12
- * @return {string|void} The filename part of the URL.
12
+ * @return The filename part of the URL.
13
13
  */
14
- export function getFilename( url ) {
14
+ export function getFilename( url: string ): string | void {
15
15
  let filename;
16
16
 
17
17
  if ( ! url ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the fragment part of the URL.
3
3
  *
4
- * @param {string} url The full URL
4
+ * @param url The full URL
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,9 +9,9 @@
9
9
  * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
10
10
  * ```
11
11
  *
12
- * @return {string|void} The fragment part of the URL.
12
+ * @return The fragment part of the URL.
13
13
  */
14
- export function getFragment( url ) {
14
+ export function getFragment( url: string ): string | void {
15
15
  const matches = /^\S+?(#[^\s\?]*)/.exec( url );
16
16
  if ( matches ) {
17
17
  return matches[ 1 ];
@@ -6,7 +6,7 @@ import { getPath, getQueryString } from '.';
6
6
  /**
7
7
  * Returns the path part and query string part of the URL.
8
8
  *
9
- * @param {string} url The full URL.
9
+ * @param url The full URL.
10
10
  *
11
11
  * @example
12
12
  * ```js
@@ -14,9 +14,9 @@ import { getPath, getQueryString } from '.';
14
14
  * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
15
15
  * ```
16
16
  *
17
- * @return {string} The path part and query string part of the URL.
17
+ * @return The path part and query string part of the URL.
18
18
  */
19
- export function getPathAndQueryString( url ) {
19
+ export function getPathAndQueryString( url: string ): string {
20
20
  const path = getPath( url );
21
21
  const queryString = getQueryString( url );
22
22
  let value = '/';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the path part of the URL.
3
3
  *
4
- * @param {string} url The full URL.
4
+ * @param url The full URL.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,9 +9,9 @@
9
9
  * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'
10
10
  * ```
11
11
  *
12
- * @return {string|void} The path part of the URL.
12
+ * @return The path part of the URL.
13
13
  */
14
- export function getPath( url ) {
14
+ export function getPath( url: string ): string | void {
15
15
  const matches =
16
16
  /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec( url );
17
17
  if ( matches ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the protocol part of the URL.
3
3
  *
4
- * @param {string} url The full URL.
4
+ * @param url The full URL.
5
5
  *
6
6
  * @example
7
7
  * ```js
@@ -9,9 +9,9 @@
9
9
  * const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'
10
10
  * ```
11
11
  *
12
- * @return {string|void} The protocol part of the URL.
12
+ * @return The protocol part of the URL.
13
13
  */
14
- export function getProtocol( url ) {
14
+ export function getProtocol( url: string ): string | void {
15
15
  const matches = /^([^\s:]+:)/.exec( url );
16
16
  if ( matches ) {
17
17
  return matches[ 1 ];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { getQueryArgs } from './get-query-args';
5
+
6
+ export interface QueryArgObject {
7
+ [ key: string ]: QueryArgParsed;
8
+ }
9
+
10
+ export type QueryArgParsed = string | string[] | QueryArgObject;
11
+
12
+ /**
13
+ * Returns a single query argument of the url
14
+ *
15
+ * @param url URL.
16
+ * @param arg Query arg name.
17
+ *
18
+ * @example
19
+ * ```js
20
+ * const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar
21
+ * ```
22
+ *
23
+ * @return Query arg value.
24
+ */
25
+ export function getQueryArg(
26
+ url: string,
27
+ arg: string
28
+ ): QueryArgParsed | undefined {
29
+ return getQueryArgs( url )[ arg ];
30
+ }
@@ -3,22 +3,19 @@
3
3
  */
4
4
  import { safeDecodeURIComponent } from './safe-decode-uri-component';
5
5
  import { getQueryString } from './get-query-string';
6
+ import type { QueryArgParsed } from './get-query-arg';
6
7
 
7
- /** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */
8
-
9
- /**
10
- * @typedef {Record<string,QueryArgParsed>} QueryArgs
11
- */
8
+ type QueryArgs = Record< string, QueryArgParsed >;
12
9
 
13
10
  /**
14
11
  * Sets a value in object deeply by a given array of path segments. Mutates the
15
12
  * object reference.
16
13
  *
17
- * @param {Record<string,*>} object Object in which to assign.
18
- * @param {string[]} path Path segment at which to set value.
19
- * @param {*} value Value to set.
14
+ * @param object Object in which to assign.
15
+ * @param path Path segment at which to set value.
16
+ * @param value Value to set.
20
17
  */
21
- function setPath( object, path, value ) {
18
+ function setPath( object: Record< string, any >, path: string[], value: any ) {
22
19
  const length = path.length;
23
20
  const lastIndex = length - 1;
24
21
  for ( let i = 0; i < length; i++ ) {
@@ -61,7 +58,7 @@ function setPath( object, path, value ) {
61
58
  * Returns an object of query arguments of the given URL. If the given URL is
62
59
  * invalid or has no querystring, an empty object is returned.
63
60
  *
64
- * @param {string} url URL.
61
+ * @param url URL.
65
62
  *
66
63
  * @example
67
64
  * ```js
@@ -69,9 +66,9 @@ function setPath( object, path, value ) {
69
66
  * // { "foo": "bar", "bar": "baz" }
70
67
  * ```
71
68
  *
72
- * @return {QueryArgs} Query args object.
69
+ * @return Query args object.
73
70
  */
74
- export function getQueryArgs( url ) {
71
+ export function getQueryArgs( url: string ): QueryArgs {
75
72
  return (
76
73
  ( getQueryString( url ) || '' )
77
74
  // Normalize space encoding, accounting for PHP URL encoding
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Returns the query string part of the URL.
3
3
  *
4
- * @param {string} url The full URL.
4
+ * @param url The full URL.
5
5
  *
6
6
  * @example
7
7
  * ```js
8
8
  * const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
9
9
  * ```
10
10
  *
11
- * @return {string|void} The query string part of the URL.
11
+ * @return The query string part of the URL.
12
12
  */
13
- export function getQueryString( url ) {
13
+ export function getQueryString( url: string ): string | void {
14
14
  let query;
15
15
  try {
16
16
  query = new URL( url, 'http://example.com' ).search.substring( 1 );
@@ -6,16 +6,16 @@ import { getQueryArg } from './get-query-arg';
6
6
  /**
7
7
  * Determines whether the URL contains a given query arg.
8
8
  *
9
- * @param {string} url URL.
10
- * @param {string} arg Query arg name.
9
+ * @param url URL.
10
+ * @param arg Query arg name.
11
11
  *
12
12
  * @example
13
13
  * ```js
14
14
  * const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
15
15
  * ```
16
16
  *
17
- * @return {boolean} Whether or not the URL contains the query arg.
17
+ * @return Whether or not the URL contains the query arg.
18
18
  */
19
- export function hasQueryArg( url, arg ) {
19
+ export function hasQueryArg( url: string, arg: string ): boolean {
20
20
  return getQueryArg( url, arg ) !== undefined;
21
21
  }
@@ -4,15 +4,15 @@ const EMAIL_REGEXP =
4
4
  /**
5
5
  * Determines whether the given string looks like an email.
6
6
  *
7
- * @param {string} email The string to scrutinise.
7
+ * @param email The string to scrutinise.
8
8
  *
9
9
  * @example
10
10
  * ```js
11
11
  * const isEmail = isEmail( 'hello@wordpress.org' ); // true
12
12
  * ```
13
13
  *
14
- * @return {boolean} Whether or not it looks like an email.
14
+ * @return Whether or not it looks like an email.
15
15
  */
16
- export function isEmail( email ) {
16
+ export function isEmail( email: string ): boolean {
17
17
  return EMAIL_REGEXP.test( email );
18
18
  }