@wordpress/url 4.32.0 → 4.32.1-next.47f435fc9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/add-query-args.js +35 -40
- package/build/add-query-args.js.map +7 -1
- package/build/build-query-string.js +30 -43
- package/build/build-query-string.js.map +7 -1
- package/build/clean-for-slug.js +39 -43
- package/build/clean-for-slug.js.map +7 -1
- package/build/filter-url-for-display.js +39 -39
- package/build/filter-url-for-display.js.map +7 -1
- package/build/get-authority.js +29 -19
- package/build/get-authority.js.map +7 -1
- package/build/get-filename.js +29 -21
- package/build/get-filename.js.map +7 -1
- package/build/get-fragment.js +26 -18
- package/build/get-fragment.js.map +7 -1
- package/build/get-path-and-query-string.js +30 -26
- package/build/get-path-and-query-string.js.map +7 -1
- package/build/get-path.js +26 -18
- package/build/get-path.js.map +7 -1
- package/build/get-protocol.js +26 -18
- package/build/get-protocol.js.map +7 -1
- package/build/get-query-arg.js +28 -24
- package/build/get-query-arg.js.map +7 -1
- package/build/get-query-args.js +42 -65
- package/build/get-query-args.js.map +7 -1
- package/build/get-query-string.js +29 -20
- package/build/get-query-string.js.map +7 -1
- package/build/has-query-arg.js +28 -24
- package/build/has-query-arg.js.map +7 -1
- package/build/index.js +109 -201
- package/build/index.js.map +7 -1
- package/build/is-email.js +26 -18
- package/build/is-email.js.map +7 -1
- package/build/is-phone-number.js +27 -20
- package/build/is-phone-number.js.map +7 -1
- package/build/is-url.js +26 -23
- package/build/is-url.js.map +7 -1
- package/build/is-valid-authority.js +26 -18
- package/build/is-valid-authority.js.map +7 -1
- package/build/is-valid-fragment.js +26 -18
- package/build/is-valid-fragment.js.map +7 -1
- package/build/is-valid-path.js +26 -18
- package/build/is-valid-path.js.map +7 -1
- package/build/is-valid-protocol.js +26 -18
- package/build/is-valid-protocol.js.map +7 -1
- package/build/is-valid-query-string.js +26 -18
- package/build/is-valid-query-string.js.map +7 -1
- package/build/normalize-path.js +28 -32
- package/build/normalize-path.js.map +7 -1
- package/build/prepend-http.js +29 -25
- package/build/prepend-http.js.map +7 -1
- package/build/prepend-https.js +30 -29
- package/build/prepend-https.js.map +7 -1
- package/build/remove-query-args.js +35 -31
- package/build/remove-query-args.js.map +7 -1
- package/build/safe-decode-uri-component.js +26 -13
- package/build/safe-decode-uri-component.js.map +7 -1
- package/build/safe-decode-uri.js +26 -18
- package/build/safe-decode-uri.js.map +7 -1
- package/build-module/add-query-args.js +12 -35
- package/build-module/add-query-args.js.map +7 -1
- package/build-module/build-query-string.js +9 -40
- package/build-module/build-query-string.js.map +7 -1
- package/build-module/clean-for-slug.js +8 -39
- package/build-module/clean-for-slug.js.map +7 -1
- package/build-module/filter-url-for-display.js +18 -36
- package/build-module/filter-url-for-display.js.map +7 -1
- package/build-module/get-authority.js +8 -16
- package/build-module/get-authority.js.map +7 -1
- package/build-module/get-filename.js +8 -18
- package/build-module/get-filename.js.map +7 -1
- package/build-module/get-fragment.js +5 -15
- package/build-module/get-fragment.js.map +7 -1
- package/build-module/get-path-and-query-string.js +7 -21
- package/build-module/get-path-and-query-string.js.map +7 -1
- package/build-module/get-path.js +5 -15
- package/build-module/get-path.js.map +7 -1
- package/build-module/get-protocol.js +5 -15
- package/build-module/get-protocol.js.map +7 -1
- package/build-module/get-query-arg.js +6 -19
- package/build-module/get-query-arg.js.map +7 -1
- package/build-module/get-query-args.js +21 -61
- package/build-module/get-query-args.js.map +7 -1
- package/build-module/get-query-string.js +8 -17
- package/build-module/get-query-string.js.map +7 -1
- package/build-module/has-query-arg.js +7 -21
- package/build-module/has-query-arg.js.map +7 -1
- package/build-module/index.js +59 -29
- package/build-module/index.js.map +7 -1
- package/build-module/is-email.js +5 -15
- package/build-module/is-email.js.map +7 -1
- package/build-module/is-phone-number.js +6 -17
- package/build-module/is-phone-number.js.map +7 -1
- package/build-module/is-url.js +5 -20
- package/build-module/is-url.js.map +7 -1
- package/build-module/is-valid-authority.js +5 -15
- package/build-module/is-valid-authority.js.map +7 -1
- package/build-module/is-valid-fragment.js +5 -15
- package/build-module/is-valid-fragment.js.map +7 -1
- package/build-module/is-valid-path.js +5 -15
- package/build-module/is-valid-path.js.map +7 -1
- package/build-module/is-valid-protocol.js +5 -15
- package/build-module/is-valid-protocol.js.map +7 -1
- package/build-module/is-valid-query-string.js +5 -15
- package/build-module/is-valid-query-string.js.map +7 -1
- package/build-module/normalize-path.js +7 -29
- package/build-module/normalize-path.js.map +7 -1
- package/build-module/prepend-http.js +7 -20
- package/build-module/prepend-http.js.map +7 -1
- package/build-module/prepend-https.js +8 -25
- package/build-module/prepend-https.js.map +7 -1
- package/build-module/remove-query-args.js +12 -26
- package/build-module/remove-query-args.js.map +7 -1
- package/build-module/safe-decode-uri-component.js +5 -10
- package/build-module/safe-decode-uri-component.js.map +7 -1
- package/build-module/safe-decode-uri.js +5 -15
- package/build-module/safe-decode-uri.js.map +7 -1
- package/package.json +10 -3
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-fragment.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the fragment part of the URL.\n *\n * @param url The full URL\n *\n * @example\n * ```js\n * const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'\n * const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'\n * ```\n *\n * @return The fragment part of the URL.\n */\nexport function getFragment( url: string ): string | void {\n\tconst matches = /^\\S+?(#[^\\s\\?]*)/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,YAAa,KAA6B;AACzD,QAAM,UAAU,mBAAmB,KAAM,GAAI;AAC7C,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_path_and_query_string_exports = {};
|
|
20
|
+
__export(get_path_and_query_string_exports, {
|
|
21
|
+
getPathAndQueryString: () => getPathAndQueryString
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the path part and query string part of the URL.
|
|
14
|
-
*
|
|
15
|
-
* @param url The full URL.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```js
|
|
19
|
-
* const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
|
|
20
|
-
* const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @return The path part and query string part of the URL.
|
|
24
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(get_path_and_query_string_exports);
|
|
24
|
+
var import__ = require(".");
|
|
25
25
|
function getPathAndQueryString(url) {
|
|
26
|
-
const path = (0,
|
|
27
|
-
const queryString = (0,
|
|
28
|
-
let value =
|
|
26
|
+
const path = (0, import__.getPath)(url);
|
|
27
|
+
const queryString = (0, import__.getQueryString)(url);
|
|
28
|
+
let value = "/";
|
|
29
29
|
if (path) {
|
|
30
30
|
value += path;
|
|
31
31
|
}
|
|
@@ -34,4 +34,8 @@ function getPathAndQueryString(url) {
|
|
|
34
34
|
}
|
|
35
35
|
return value;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
getPathAndQueryString
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=get-path-and-query-string.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-path-and-query-string.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getPath, getQueryString } from '.';\n\n/**\n * Returns the path part and query string part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'\n * const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'\n * ```\n *\n * @return The path part and query string part of the URL.\n */\nexport function getPathAndQueryString( url: string ): string {\n\tconst path = getPath( url );\n\tconst queryString = getQueryString( url );\n\tlet value = '/';\n\tif ( path ) {\n\t\tvalue += path;\n\t}\n\tif ( queryString ) {\n\t\tvalue += `?${ queryString }`;\n\t}\n\treturn value;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,eAAwC;AAejC,SAAS,sBAAuB,KAAsB;AAC5D,QAAM,WAAO,kBAAS,GAAI;AAC1B,QAAM,kBAAc,yBAAgB,GAAI;AACxC,MAAI,QAAQ;AACZ,MAAK,MAAO;AACX,aAAS;AAAA,EACV;AACA,MAAK,aAAc;AAClB,aAAS,IAAK,WAAY;AAAA,EAC3B;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/get-path.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_path_exports = {};
|
|
20
|
+
__export(get_path_exports, {
|
|
21
|
+
getPath: () => getPath
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
/**
|
|
8
|
-
* Returns the path part of the URL.
|
|
9
|
-
*
|
|
10
|
-
* @param url The full URL.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```js
|
|
14
|
-
* const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'
|
|
15
|
-
* const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @return The path part of the URL.
|
|
19
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(get_path_exports);
|
|
20
24
|
function getPath(url) {
|
|
21
25
|
const matches = /^[^\/\s:]+:(?:\/\/)?[^\/\s#?]+[\/]([^\s#?]+)[#?]{0,1}\S*$/.exec(url);
|
|
22
26
|
if (matches) {
|
|
23
27
|
return matches[1];
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
getPath
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=get-path.js.map
|
package/build/get-path.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-path.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the path part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const path1 = getPath( 'http://localhost:8080/this/is/a/test?query=true' ); // 'this/is/a/test'\n * const path2 = getPath( 'https://wordpress.org/help/faq/' ); // 'help/faq'\n * ```\n *\n * @return The path part of the URL.\n */\nexport function getPath( url: string ): string | void {\n\tconst matches =\n\t\t/^[^\\/\\s:]+:(?:\\/\\/)?[^\\/\\s#?]+[\\/]([^\\s#?]+)[#?]{0,1}\\S*$/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,QAAS,KAA6B;AACrD,QAAM,UACL,4DAA4D,KAAM,GAAI;AACvE,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/get-protocol.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_protocol_exports = {};
|
|
20
|
+
__export(get_protocol_exports, {
|
|
21
|
+
getProtocol: () => getProtocol
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
/**
|
|
8
|
-
* Returns the protocol part of the URL.
|
|
9
|
-
*
|
|
10
|
-
* @param url The full URL.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```js
|
|
14
|
-
* const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'
|
|
15
|
-
* const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @return The protocol part of the URL.
|
|
19
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(get_protocol_exports);
|
|
20
24
|
function getProtocol(url) {
|
|
21
25
|
const matches = /^([^\s:]+:)/.exec(url);
|
|
22
26
|
if (matches) {
|
|
23
27
|
return matches[1];
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
getProtocol
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=get-protocol.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-protocol.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the protocol part of the URL.\n *\n * @param 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 The protocol part of the URL.\n */\nexport function getProtocol( url: string ): string | void {\n\tconst matches = /^([^\\s:]+:)/.exec( url );\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,YAAa,KAA6B;AACzD,QAAM,UAAU,cAAc,KAAM,GAAI;AACxC,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/get-query-arg.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_query_arg_exports = {};
|
|
20
|
+
__export(get_query_arg_exports, {
|
|
21
|
+
getQueryArg: () => getQueryArg
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
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
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(get_query_arg_exports);
|
|
24
|
+
var import_get_query_args = require("./get-query-args");
|
|
25
25
|
function getQueryArg(url, arg) {
|
|
26
|
-
return (0,
|
|
26
|
+
return (0, import_get_query_args.getQueryArgs)(url)[arg];
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
getQueryArg
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=get-query-arg.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-query-arg.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\nexport interface QueryArgObject {\n\t[ key: string ]: QueryArgParsed;\n}\n\nexport type QueryArgParsed = string | string[] | QueryArgObject;\n\n/**\n * Returns a single query argument of the url\n *\n * @param url URL.\n * @param 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 Query arg value.\n */\nexport function getQueryArg(\n\turl: string,\n\targ: string\n): QueryArgParsed | undefined {\n\treturn getQueryArgs( url )[ arg ];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,4BAA6B;AAqBtB,SAAS,YACf,KACA,KAC6B;AAC7B,aAAO,oCAAc,GAAI,EAAG,GAAI;AACjC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/get-query-args.js
CHANGED
|
@@ -1,87 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_query_args_exports = {};
|
|
20
|
+
__export(get_query_args_exports, {
|
|
21
|
+
getQueryArgs: () => getQueryArgs
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Sets a value in object deeply by a given array of path segments. Mutates the
|
|
15
|
-
* object reference.
|
|
16
|
-
*
|
|
17
|
-
* @param object Object in which to assign.
|
|
18
|
-
* @param path Path segment at which to set value.
|
|
19
|
-
* @param value Value to set.
|
|
20
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(get_query_args_exports);
|
|
24
|
+
var import_safe_decode_uri_component = require("./safe-decode-uri-component");
|
|
25
|
+
var import_get_query_string = require("./get-query-string");
|
|
21
26
|
function setPath(object, path, value) {
|
|
22
27
|
const length = path.length;
|
|
23
28
|
const lastIndex = length - 1;
|
|
24
29
|
for (let i = 0; i < length; i++) {
|
|
25
30
|
let key = path[i];
|
|
26
31
|
if (!key && Array.isArray(object)) {
|
|
27
|
-
// If key is empty string and next value is array, derive key from
|
|
28
|
-
// the current length of the array.
|
|
29
32
|
key = object.length.toString();
|
|
30
33
|
}
|
|
31
|
-
key = [
|
|
32
|
-
|
|
33
|
-
// If the next key in the path is numeric (or empty string), it will be
|
|
34
|
-
// created as an array. Otherwise, it will be created as an object.
|
|
34
|
+
key = ["__proto__", "constructor", "prototype"].includes(key) ? key.toUpperCase() : key;
|
|
35
35
|
const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
|
|
36
|
-
object[key] = i === lastIndex ?
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
object[key] = i === lastIndex ? (
|
|
37
|
+
// If at end of path, assign the intended value.
|
|
38
|
+
value
|
|
39
|
+
) : (
|
|
40
|
+
// Otherwise, advance to the next object in the path, creating
|
|
41
|
+
// it if it does not yet exist.
|
|
42
|
+
object[key] || (isNextKeyArrayIndex ? [] : {})
|
|
43
|
+
);
|
|
42
44
|
if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
|
|
43
|
-
|
|
44
|
-
// array, coerce the value to an object.
|
|
45
|
-
object[key] = {
|
|
46
|
-
...object[key]
|
|
47
|
-
};
|
|
45
|
+
object[key] = { ...object[key] };
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
// Update working reference object to the next in the path.
|
|
51
47
|
object = object[key];
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns an object of query arguments of the given URL. If the given URL is
|
|
57
|
-
* invalid or has no querystring, an empty object is returned.
|
|
58
|
-
*
|
|
59
|
-
* @param url URL.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```js
|
|
63
|
-
* const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );
|
|
64
|
-
* // { "foo": "bar", "bar": "baz" }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @return Query args object.
|
|
68
|
-
*/
|
|
69
50
|
function getQueryArgs(url) {
|
|
70
|
-
return ((0,
|
|
71
|
-
|
|
72
|
-
// corresponding to `application/x-www-form-urlencoded`.
|
|
73
|
-
//
|
|
74
|
-
// See: https://tools.ietf.org/html/rfc1866#section-8.2.1
|
|
75
|
-
).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => {
|
|
76
|
-
const [key, value = ''] = keyValue.split('=')
|
|
77
|
-
// Filtering avoids decoding as `undefined` for value, where
|
|
78
|
-
// default is restored in destructuring assignment.
|
|
79
|
-
.filter(Boolean).map(_safeDecodeUriComponent.safeDecodeURIComponent);
|
|
51
|
+
return ((0, import_get_query_string.getQueryString)(url) || "").replace(/\+/g, "%20").split("&").reduce((accumulator, keyValue) => {
|
|
52
|
+
const [key, value = ""] = keyValue.split("=").filter(Boolean).map(import_safe_decode_uri_component.safeDecodeURIComponent);
|
|
80
53
|
if (key) {
|
|
81
|
-
const segments = key.replace(/\]/g,
|
|
54
|
+
const segments = key.replace(/\]/g, "").split("[");
|
|
82
55
|
setPath(accumulator, segments, value);
|
|
83
56
|
}
|
|
84
57
|
return accumulator;
|
|
85
|
-
}, Object.create(null));
|
|
58
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
86
59
|
}
|
|
87
|
-
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
getQueryArgs
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=get-query-args.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-query-args.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { safeDecodeURIComponent } from './safe-decode-uri-component';\nimport { getQueryString } from './get-query-string';\nimport type { QueryArgParsed } from './get-query-arg';\n\ntype QueryArgs = Record< string, QueryArgParsed >;\n\n/**\n * Sets a value in object deeply by a given array of path segments. Mutates the\n * object reference.\n *\n * @param object Object in which to assign.\n * @param path Path segment at which to set value.\n * @param value Value to set.\n */\nfunction setPath( object: Record< string, any >, path: string[], value: any ) {\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 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 Query args object.\n */\nexport function getQueryArgs( url: string ): QueryArgs {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uCAAuC;AACvC,8BAA+B;AAa/B,SAAS,QAAS,QAA+B,MAAgB,OAAa;AAC7E,QAAM,SAAS,KAAK;AACpB,QAAM,YAAY,SAAS;AAC3B,WAAU,IAAI,GAAG,IAAI,QAAQ,KAAM;AAClC,QAAI,MAAM,KAAM,CAAE;AAElB,QAAK,CAAE,OAAO,MAAM,QAAS,MAAO,GAAI;AAGvC,YAAM,OAAO,OAAO,SAAS;AAAA,IAC9B;AAEA,UAAM,CAAE,aAAa,eAAe,WAAY,EAAE,SAAU,GAAI,IAC7D,IAAI,YAAY,IAChB;AAIH,UAAM,sBAAsB,CAAE,MAAO,OAAQ,KAAM,IAAI,CAAE,CAAE,CAAE;AAE7D,WAAQ,GAAI,IACX,MAAM;AAAA;AAAA,MAEH;AAAA;AAAA;AAAA;AAAA,MAGA,OAAQ,GAAI,MAAO,sBAAsB,CAAC,IAAI,CAAC;AAAA;AAEnD,QAAK,MAAM,QAAS,OAAQ,GAAI,CAAE,KAAK,CAAE,qBAAsB;AAG9D,aAAQ,GAAI,IAAI,EAAE,GAAG,OAAQ,GAAI,EAAE;AAAA,IACpC;AAGA,aAAS,OAAQ,GAAI;AAAA,EACtB;AACD;AAgBO,SAAS,aAAc,KAAyB;AACtD,cACG,wCAAgB,GAAI,KAAK,IAKzB,QAAS,OAAO,KAAM,EACtB,MAAO,GAAI,EACX,OAAQ,CAAE,aAAa,aAAc;AACrC,UAAM,CAAE,KAAK,QAAQ,EAAG,IAAI,SAC1B,MAAO,GAAI,EAGX,OAAQ,OAAQ,EAChB,IAAK,uDAAuB;AAE9B,QAAK,KAAM;AACV,YAAM,WAAW,IAAI,QAAS,OAAO,EAAG,EAAE,MAAO,GAAI;AACrD,cAAS,aAAa,UAAU,KAAM;AAAA,IACvC;AAEA,WAAO;AAAA,EACR,GAAG,uBAAO,OAAQ,IAAK,CAAE;AAE5B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
/* wp:polyfill */
|
|
2
1
|
"use strict";
|
|
3
|
-
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_query_string_exports = {};
|
|
20
|
+
__export(get_query_string_exports, {
|
|
21
|
+
getQueryString: () => getQueryString
|
|
6
22
|
});
|
|
7
|
-
exports
|
|
8
|
-
/**
|
|
9
|
-
* Returns the query string part of the URL.
|
|
10
|
-
*
|
|
11
|
-
* @param url The full URL.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```js
|
|
15
|
-
* const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @return The query string part of the URL.
|
|
19
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(get_query_string_exports);
|
|
20
24
|
function getQueryString(url) {
|
|
21
25
|
let query;
|
|
22
26
|
try {
|
|
23
|
-
query = new URL(url,
|
|
24
|
-
} catch (error) {
|
|
27
|
+
query = new URL(url, "http://example.com").search.substring(1);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
}
|
|
25
30
|
if (query) {
|
|
26
31
|
return query;
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
|
-
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
getQueryString
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=get-query-string.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-query-string.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the query string part of the URL.\n *\n * @param 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 The query string part of the URL.\n */\nexport function getQueryString( url: string ): string | void {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,eAAgB,KAA6B;AAC5D,MAAI;AACJ,MAAI;AACH,YAAQ,IAAI,IAAK,KAAK,oBAAqB,EAAE,OAAO,UAAW,CAAE;AAAA,EAClE,SAAU,OAAQ;AAAA,EAAC;AAEnB,MAAK,OAAQ;AACZ,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/has-query-arg.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var has_query_arg_exports = {};
|
|
20
|
+
__export(has_query_arg_exports, {
|
|
21
|
+
hasQueryArg: () => hasQueryArg
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Determines whether the URL contains a given query arg.
|
|
14
|
-
*
|
|
15
|
-
* @param url URL.
|
|
16
|
-
* @param arg Query arg name.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```js
|
|
20
|
-
* const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @return Whether or not the URL contains the query arg.
|
|
24
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(has_query_arg_exports);
|
|
24
|
+
var import_get_query_arg = require("./get-query-arg");
|
|
25
25
|
function hasQueryArg(url, arg) {
|
|
26
|
-
return (0,
|
|
26
|
+
return (0, import_get_query_arg.getQueryArg)(url, arg) !== void 0;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
hasQueryArg
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=has-query-arg.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/has-query-arg.ts"],
|
|
4
|
+
"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 url URL.\n * @param 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 Whether or not the URL contains the query arg.\n */\nexport function hasQueryArg( url: string, arg: string ): boolean {\n\treturn getQueryArg( url, arg ) !== undefined;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,2BAA4B;AAerB,SAAS,YAAa,KAAa,KAAuB;AAChE,aAAO,kCAAa,KAAK,GAAI,MAAM;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|