@wordpress/url 4.26.1-next.719a03cbe.0 → 4.27.1-next.46f643fa0.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.
- package/CHANGELOG.md +2 -0
- package/README.md +12 -12
- package/build/add-query-args.js +4 -4
- package/build/add-query-args.js.map +1 -1
- package/build/build-query-string.js +3 -3
- package/build/build-query-string.js.map +1 -1
- package/build/clean-for-slug.js +2 -2
- package/build/clean-for-slug.js.map +1 -1
- package/build/filter-url-for-display.js +3 -3
- package/build/filter-url-for-display.js.map +1 -1
- package/build/get-authority.js +2 -2
- package/build/get-authority.js.map +1 -1
- package/build/get-filename.js +2 -2
- package/build/get-filename.js.map +1 -1
- package/build/get-fragment.js +2 -2
- package/build/get-fragment.js.map +1 -1
- package/build/get-path-and-query-string.js +2 -2
- package/build/get-path-and-query-string.js.map +1 -1
- package/build/get-path.js +2 -2
- package/build/get-path.js.map +1 -1
- package/build/get-protocol.js +2 -2
- package/build/get-protocol.js.map +1 -1
- package/build/get-query-arg.js +3 -11
- package/build/get-query-arg.js.map +1 -1
- package/build/get-query-args.js +5 -11
- package/build/get-query-args.js.map +1 -1
- package/build/get-query-string.js +2 -2
- package/build/get-query-string.js.map +1 -1
- package/build/has-query-arg.js +3 -3
- package/build/has-query-arg.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/is-email.js +2 -2
- package/build/is-email.js.map +1 -1
- package/build/is-phone-number.js +2 -2
- package/build/is-phone-number.js.map +1 -1
- package/build/is-url.js +2 -2
- package/build/is-url.js.map +1 -1
- package/build/is-valid-authority.js +2 -2
- package/build/is-valid-authority.js.map +1 -1
- package/build/is-valid-fragment.js +2 -2
- package/build/is-valid-fragment.js.map +1 -1
- package/build/is-valid-path.js +2 -2
- package/build/is-valid-path.js.map +1 -1
- package/build/is-valid-protocol.js +2 -2
- package/build/is-valid-protocol.js.map +1 -1
- package/build/is-valid-query-string.js +2 -2
- package/build/is-valid-query-string.js.map +1 -1
- package/build/normalize-path.js +2 -2
- package/build/normalize-path.js.map +1 -1
- package/build/prepend-http.js +2 -2
- package/build/prepend-http.js.map +1 -1
- package/build/prepend-https.js +2 -2
- package/build/prepend-https.js.map +1 -1
- package/build/remove-query-args.js +3 -3
- package/build/remove-query-args.js.map +1 -1
- package/build/safe-decode-uri-component.js +2 -2
- package/build/safe-decode-uri-component.js.map +1 -1
- package/build/safe-decode-uri.js +2 -2
- package/build/safe-decode-uri.js.map +1 -1
- package/build-module/add-query-args.js +4 -4
- package/build-module/add-query-args.js.map +1 -1
- package/build-module/build-query-string.js +3 -3
- package/build-module/build-query-string.js.map +1 -1
- package/build-module/clean-for-slug.js +2 -2
- package/build-module/clean-for-slug.js.map +1 -1
- package/build-module/filter-url-for-display.js +3 -3
- package/build-module/filter-url-for-display.js.map +1 -1
- package/build-module/get-authority.js +2 -2
- package/build-module/get-authority.js.map +1 -1
- package/build-module/get-filename.js +2 -2
- package/build-module/get-filename.js.map +1 -1
- package/build-module/get-fragment.js +2 -2
- package/build-module/get-fragment.js.map +1 -1
- package/build-module/get-path-and-query-string.js +2 -2
- package/build-module/get-path-and-query-string.js.map +1 -1
- package/build-module/get-path.js +2 -2
- package/build-module/get-path.js.map +1 -1
- package/build-module/get-protocol.js +2 -2
- package/build-module/get-protocol.js.map +1 -1
- package/build-module/get-query-arg.js +3 -12
- package/build-module/get-query-arg.js.map +1 -1
- package/build-module/get-query-args.js +5 -12
- package/build-module/get-query-args.js.map +1 -1
- package/build-module/get-query-string.js +2 -2
- package/build-module/get-query-string.js.map +1 -1
- package/build-module/has-query-arg.js +3 -3
- package/build-module/has-query-arg.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/is-email.js +2 -2
- package/build-module/is-email.js.map +1 -1
- package/build-module/is-phone-number.js +2 -2
- package/build-module/is-phone-number.js.map +1 -1
- package/build-module/is-url.js +2 -2
- package/build-module/is-url.js.map +1 -1
- package/build-module/is-valid-authority.js +2 -2
- package/build-module/is-valid-authority.js.map +1 -1
- package/build-module/is-valid-fragment.js +2 -2
- package/build-module/is-valid-fragment.js.map +1 -1
- package/build-module/is-valid-path.js +2 -2
- package/build-module/is-valid-path.js.map +1 -1
- package/build-module/is-valid-protocol.js +2 -2
- package/build-module/is-valid-protocol.js.map +1 -1
- package/build-module/is-valid-query-string.js +2 -2
- package/build-module/is-valid-query-string.js.map +1 -1
- package/build-module/normalize-path.js +2 -2
- package/build-module/normalize-path.js.map +1 -1
- package/build-module/prepend-http.js +2 -2
- package/build-module/prepend-http.js.map +1 -1
- package/build-module/prepend-https.js +2 -2
- package/build-module/prepend-https.js.map +1 -1
- package/build-module/remove-query-args.js +3 -3
- package/build-module/remove-query-args.js.map +1 -1
- package/build-module/safe-decode-uri-component.js +2 -2
- package/build-module/safe-decode-uri-component.js.map +1 -1
- package/build-module/safe-decode-uri.js +2 -2
- package/build-module/safe-decode-uri.js.map +1 -1
- package/build-types/add-query-args.d.ts +5 -5
- package/build-types/add-query-args.d.ts.map +1 -1
- package/build-types/build-query-string.d.ts +3 -3
- package/build-types/build-query-string.d.ts.map +1 -1
- package/build-types/clean-for-slug.d.ts +3 -3
- package/build-types/clean-for-slug.d.ts.map +1 -1
- package/build-types/filter-url-for-display.d.ts +4 -4
- package/build-types/filter-url-for-display.d.ts.map +1 -1
- package/build-types/get-authority.d.ts +3 -3
- package/build-types/get-authority.d.ts.map +1 -1
- package/build-types/get-filename.d.ts +3 -3
- package/build-types/get-filename.d.ts.map +1 -1
- package/build-types/get-fragment.d.ts +3 -3
- package/build-types/get-fragment.d.ts.map +1 -1
- package/build-types/get-path-and-query-string.d.ts +3 -3
- package/build-types/get-path-and-query-string.d.ts.map +1 -1
- package/build-types/get-path.d.ts +3 -3
- package/build-types/get-path.d.ts.map +1 -1
- package/build-types/get-protocol.d.ts +3 -3
- package/build-types/get-protocol.d.ts.map +1 -1
- package/build-types/get-query-arg.d.ts +8 -14
- package/build-types/get-query-arg.d.ts.map +1 -1
- package/build-types/get-query-args.d.ts +6 -5
- package/build-types/get-query-args.d.ts.map +1 -1
- package/build-types/get-query-string.d.ts +3 -3
- package/build-types/get-query-string.d.ts.map +1 -1
- package/build-types/has-query-arg.d.ts +4 -4
- package/build-types/has-query-arg.d.ts.map +1 -1
- package/build-types/index.d.ts +28 -28
- package/build-types/index.d.ts.map +1 -1
- package/build-types/is-email.d.ts +3 -3
- package/build-types/is-email.d.ts.map +1 -1
- package/build-types/is-phone-number.d.ts +3 -3
- package/build-types/is-phone-number.d.ts.map +1 -1
- package/build-types/is-url.d.ts +3 -3
- package/build-types/is-url.d.ts.map +1 -1
- package/build-types/is-valid-authority.d.ts +3 -3
- package/build-types/is-valid-authority.d.ts.map +1 -1
- package/build-types/is-valid-fragment.d.ts +3 -3
- package/build-types/is-valid-fragment.d.ts.map +1 -1
- package/build-types/is-valid-path.d.ts +3 -3
- package/build-types/is-valid-path.d.ts.map +1 -1
- package/build-types/is-valid-protocol.d.ts +3 -3
- package/build-types/is-valid-protocol.d.ts.map +1 -1
- package/build-types/is-valid-query-string.d.ts +3 -3
- package/build-types/is-valid-query-string.d.ts.map +1 -1
- package/build-types/normalize-path.d.ts +3 -3
- package/build-types/normalize-path.d.ts.map +1 -1
- package/build-types/prepend-http.d.ts +3 -3
- package/build-types/prepend-http.d.ts.map +1 -1
- package/build-types/prepend-https.d.ts +3 -3
- package/build-types/prepend-https.d.ts.map +1 -1
- package/build-types/remove-query-args.d.ts +4 -4
- package/build-types/remove-query-args.d.ts.map +1 -1
- package/build-types/safe-decode-uri-component.d.ts +3 -3
- package/build-types/safe-decode-uri-component.d.ts.map +1 -1
- package/build-types/safe-decode-uri.d.ts +3 -3
- package/build-types/safe-decode-uri.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/{add-query-args.js → add-query-args.ts} +8 -5
- package/src/{build-query-string.js → build-query-string.ts} +7 -6
- package/src/{clean-for-slug.js → clean-for-slug.ts} +3 -3
- package/src/{filter-url-for-display.js → filter-url-for-display.ts} +7 -4
- package/src/{get-authority.js → get-authority.ts} +3 -3
- package/src/{get-filename.js → get-filename.ts} +3 -3
- package/src/{get-fragment.js → get-fragment.ts} +3 -3
- package/src/{get-path-and-query-string.js → get-path-and-query-string.ts} +3 -3
- package/src/{get-path.js → get-path.ts} +3 -3
- package/src/{get-protocol.js → get-protocol.ts} +3 -3
- package/src/get-query-arg.ts +30 -0
- package/src/{get-query-args.js → get-query-args.ts} +9 -12
- package/src/{get-query-string.js → get-query-string.ts} +3 -3
- package/src/{has-query-arg.js → has-query-arg.ts} +4 -4
- package/src/{is-email.js → is-email.ts} +3 -3
- package/src/{is-phone-number.js → is-phone-number.ts} +3 -3
- package/src/{is-url.js → is-url.ts} +3 -3
- package/src/{is-valid-authority.js → is-valid-authority.ts} +3 -3
- package/src/{is-valid-fragment.js → is-valid-fragment.ts} +3 -3
- package/src/{is-valid-path.js → is-valid-path.ts} +3 -3
- package/src/{is-valid-protocol.js → is-valid-protocol.ts} +3 -3
- package/src/{is-valid-query-string.js → is-valid-query-string.ts} +3 -3
- package/src/{normalize-path.js → normalize-path.ts} +3 -3
- package/src/{prepend-http.js → prepend-http.ts} +3 -3
- package/src/{prepend-https.js → prepend-https.ts} +3 -3
- package/src/{remove-query-args.js → remove-query-args.ts} +4 -4
- package/src/{safe-decode-uri-component.js → safe-decode-uri-component.ts} +3 -3
- package/src/{safe-decode-uri.js → safe-decode-uri.ts} +3 -3
- package/src/test/index.js +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/get-query-arg.js +0 -29
- /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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
6
|
+
* @param path Original path.
|
|
7
7
|
*
|
|
8
|
-
* @return
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
5
|
-
* @param
|
|
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
|
|
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.
|
|
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
|
|
5
|
+
* @param uriComponent URI component to decode.
|
|
6
6
|
*
|
|
7
|
-
* @return
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
3
|
+
"version": "4.27.1-next.46f643fa0.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": "
|
|
38
|
+
"gitHead": "17e600e091675c5e3d809adfea23ac456bbeae19"
|
|
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
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
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
|
|
22
|
+
* @return URL with arguments applied.
|
|
23
23
|
*/
|
|
24
|
-
export function addQueryArgs(
|
|
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
|
|
21
|
+
* @param data Data to encode.
|
|
22
22
|
*
|
|
23
|
-
* @return
|
|
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
|
-
'&' +
|
|
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
|
|
18
|
+
* @param string Title or slug to be processed.
|
|
19
19
|
*
|
|
20
|
-
* @return
|
|
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
|
|
5
|
-
* @param
|
|
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
|
|
13
|
+
* @return Displayed URL.
|
|
14
14
|
*/
|
|
15
|
-
export function filterURLForDisplay(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
10
|
-
* @param
|
|
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
|
|
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
|
|
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
|
|
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
|
}
|