@wordpress/url 4.32.0 → 4.32.1-next.ff1cebbba.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,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Returns the protocol part of the URL.
|
|
3
|
-
*
|
|
4
|
-
* @param url The full URL.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const protocol1 = getProtocol( 'tel:012345678' ); // 'tel:'
|
|
9
|
-
* const protocol2 = getProtocol( 'https://wordpress.org' ); // 'https:'
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return The protocol part of the URL.
|
|
13
|
-
*/
|
|
14
|
-
export function getProtocol(url) {
|
|
1
|
+
function getProtocol(url) {
|
|
15
2
|
const matches = /^([^\s:]+:)/.exec(url);
|
|
16
3
|
if (matches) {
|
|
17
4
|
return matches[1];
|
|
18
5
|
}
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
getProtocol
|
|
9
|
+
};
|
|
10
|
+
//# 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": "AAaO,SAAS,YAAa,KAA6B;AACzD,QAAM,UAAU,cAAc,KAAM,GAAI;AACxC,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { getQueryArgs } from './get-query-args';
|
|
5
|
-
/**
|
|
6
|
-
* Returns a single query argument of the url
|
|
7
|
-
*
|
|
8
|
-
* @param url URL.
|
|
9
|
-
* @param arg Query arg name.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```js
|
|
13
|
-
* const foo = getQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'foo' ); // bar
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @return Query arg value.
|
|
17
|
-
*/
|
|
18
|
-
export function getQueryArg(url, arg) {
|
|
1
|
+
import { getQueryArgs } from "./get-query-args";
|
|
2
|
+
function getQueryArg(url, arg) {
|
|
19
3
|
return getQueryArgs(url)[arg];
|
|
20
4
|
}
|
|
21
|
-
|
|
5
|
+
export {
|
|
6
|
+
getQueryArg
|
|
7
|
+
};
|
|
8
|
+
//# 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": "AAGA,SAAS,oBAAoB;AAqBtB,SAAS,YACf,KACA,KAC6B;AAC7B,SAAO,aAAc,GAAI,EAAG,GAAI;AACjC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,80 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { safeDecodeURIComponent } from './safe-decode-uri-component';
|
|
5
|
-
import { getQueryString } from './get-query-string';
|
|
6
|
-
/**
|
|
7
|
-
* Sets a value in object deeply by a given array of path segments. Mutates the
|
|
8
|
-
* object reference.
|
|
9
|
-
*
|
|
10
|
-
* @param object Object in which to assign.
|
|
11
|
-
* @param path Path segment at which to set value.
|
|
12
|
-
* @param value Value to set.
|
|
13
|
-
*/
|
|
1
|
+
import { safeDecodeURIComponent } from "./safe-decode-uri-component";
|
|
2
|
+
import { getQueryString } from "./get-query-string";
|
|
14
3
|
function setPath(object, path, value) {
|
|
15
4
|
const length = path.length;
|
|
16
5
|
const lastIndex = length - 1;
|
|
17
6
|
for (let i = 0; i < length; i++) {
|
|
18
7
|
let key = path[i];
|
|
19
8
|
if (!key && Array.isArray(object)) {
|
|
20
|
-
// If key is empty string and next value is array, derive key from
|
|
21
|
-
// the current length of the array.
|
|
22
9
|
key = object.length.toString();
|
|
23
10
|
}
|
|
24
|
-
key = [
|
|
25
|
-
|
|
26
|
-
// If the next key in the path is numeric (or empty string), it will be
|
|
27
|
-
// created as an array. Otherwise, it will be created as an object.
|
|
11
|
+
key = ["__proto__", "constructor", "prototype"].includes(key) ? key.toUpperCase() : key;
|
|
28
12
|
const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
|
|
29
|
-
object[key] = i === lastIndex ?
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
object[key] = i === lastIndex ? (
|
|
14
|
+
// If at end of path, assign the intended value.
|
|
15
|
+
value
|
|
16
|
+
) : (
|
|
17
|
+
// Otherwise, advance to the next object in the path, creating
|
|
18
|
+
// it if it does not yet exist.
|
|
19
|
+
object[key] || (isNextKeyArrayIndex ? [] : {})
|
|
20
|
+
);
|
|
35
21
|
if (Array.isArray(object[key]) && !isNextKeyArrayIndex) {
|
|
36
|
-
|
|
37
|
-
// array, coerce the value to an object.
|
|
38
|
-
object[key] = {
|
|
39
|
-
...object[key]
|
|
40
|
-
};
|
|
22
|
+
object[key] = { ...object[key] };
|
|
41
23
|
}
|
|
42
|
-
|
|
43
|
-
// Update working reference object to the next in the path.
|
|
44
24
|
object = object[key];
|
|
45
25
|
}
|
|
46
26
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* invalid or has no querystring, an empty object is returned.
|
|
51
|
-
*
|
|
52
|
-
* @param url URL.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```js
|
|
56
|
-
* const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );
|
|
57
|
-
* // { "foo": "bar", "bar": "baz" }
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @return Query args object.
|
|
61
|
-
*/
|
|
62
|
-
export function getQueryArgs(url) {
|
|
63
|
-
return (getQueryString(url) || ''
|
|
64
|
-
// Normalize space encoding, accounting for PHP URL encoding
|
|
65
|
-
// corresponding to `application/x-www-form-urlencoded`.
|
|
66
|
-
//
|
|
67
|
-
// See: https://tools.ietf.org/html/rfc1866#section-8.2.1
|
|
68
|
-
).replace(/\+/g, '%20').split('&').reduce((accumulator, keyValue) => {
|
|
69
|
-
const [key, value = ''] = keyValue.split('=')
|
|
70
|
-
// Filtering avoids decoding as `undefined` for value, where
|
|
71
|
-
// default is restored in destructuring assignment.
|
|
72
|
-
.filter(Boolean).map(safeDecodeURIComponent);
|
|
27
|
+
function getQueryArgs(url) {
|
|
28
|
+
return (getQueryString(url) || "").replace(/\+/g, "%20").split("&").reduce((accumulator, keyValue) => {
|
|
29
|
+
const [key, value = ""] = keyValue.split("=").filter(Boolean).map(safeDecodeURIComponent);
|
|
73
30
|
if (key) {
|
|
74
|
-
const segments = key.replace(/\]/g,
|
|
31
|
+
const segments = key.replace(/\]/g, "").split("[");
|
|
75
32
|
setPath(accumulator, segments, value);
|
|
76
33
|
}
|
|
77
34
|
return accumulator;
|
|
78
|
-
}, Object.create(null));
|
|
35
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
79
36
|
}
|
|
80
|
-
|
|
37
|
+
export {
|
|
38
|
+
getQueryArgs
|
|
39
|
+
};
|
|
40
|
+
//# 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": "AAGA,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;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,UACG,eAAgB,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,sBAAuB;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,23 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Returns the query string part of the URL.
|
|
4
|
-
*
|
|
5
|
-
* @param url The full URL.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return The query string part of the URL.
|
|
13
|
-
*/
|
|
14
|
-
export function getQueryString(url) {
|
|
1
|
+
function getQueryString(url) {
|
|
15
2
|
let query;
|
|
16
3
|
try {
|
|
17
|
-
query = new URL(url,
|
|
18
|
-
} catch (error) {
|
|
4
|
+
query = new URL(url, "http://example.com").search.substring(1);
|
|
5
|
+
} catch (error) {
|
|
6
|
+
}
|
|
19
7
|
if (query) {
|
|
20
8
|
return query;
|
|
21
9
|
}
|
|
22
10
|
}
|
|
23
|
-
|
|
11
|
+
export {
|
|
12
|
+
getQueryString
|
|
13
|
+
};
|
|
14
|
+
//# 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": "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
|
+
}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { getQueryArg } from './get-query-arg';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Determines whether the URL contains a given query arg.
|
|
8
|
-
*
|
|
9
|
-
* @param url URL.
|
|
10
|
-
* @param arg Query arg name.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```js
|
|
14
|
-
* const hasBar = hasQueryArg( 'https://wordpress.org?foo=bar&bar=baz', 'bar' ); // true
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @return Whether or not the URL contains the query arg.
|
|
18
|
-
*/
|
|
19
|
-
export function hasQueryArg(url, arg) {
|
|
20
|
-
return getQueryArg(url, arg) !== undefined;
|
|
1
|
+
import { getQueryArg } from "./get-query-arg";
|
|
2
|
+
function hasQueryArg(url, arg) {
|
|
3
|
+
return getQueryArg(url, arg) !== void 0;
|
|
21
4
|
}
|
|
22
|
-
|
|
5
|
+
export {
|
|
6
|
+
hasQueryArg
|
|
7
|
+
};
|
|
8
|
+
//# 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": "AAGA,SAAS,mBAAmB;AAerB,SAAS,YAAa,KAAa,KAAuB;AAChE,SAAO,YAAa,KAAK,GAAI,MAAM;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,29 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
import { isURL } from "./is-url";
|
|
2
|
+
import { isEmail } from "./is-email";
|
|
3
|
+
import { isPhoneNumber } from "./is-phone-number";
|
|
4
|
+
import { getProtocol } from "./get-protocol";
|
|
5
|
+
import { isValidProtocol } from "./is-valid-protocol";
|
|
6
|
+
import { getAuthority } from "./get-authority";
|
|
7
|
+
import { isValidAuthority } from "./is-valid-authority";
|
|
8
|
+
import { getPath } from "./get-path";
|
|
9
|
+
import { isValidPath } from "./is-valid-path";
|
|
10
|
+
import { getQueryString } from "./get-query-string";
|
|
11
|
+
import { buildQueryString } from "./build-query-string";
|
|
12
|
+
import { isValidQueryString } from "./is-valid-query-string";
|
|
13
|
+
import { getPathAndQueryString } from "./get-path-and-query-string";
|
|
14
|
+
import { getFragment } from "./get-fragment";
|
|
15
|
+
import { isValidFragment } from "./is-valid-fragment";
|
|
16
|
+
import { addQueryArgs } from "./add-query-args";
|
|
17
|
+
import { getQueryArg } from "./get-query-arg";
|
|
18
|
+
import { getQueryArgs } from "./get-query-args";
|
|
19
|
+
import { hasQueryArg } from "./has-query-arg";
|
|
20
|
+
import { removeQueryArgs } from "./remove-query-args";
|
|
21
|
+
import { prependHTTP } from "./prepend-http";
|
|
22
|
+
import { safeDecodeURI } from "./safe-decode-uri";
|
|
23
|
+
import { safeDecodeURIComponent } from "./safe-decode-uri-component";
|
|
24
|
+
import { filterURLForDisplay } from "./filter-url-for-display";
|
|
25
|
+
import { cleanForSlug } from "./clean-for-slug";
|
|
26
|
+
import { getFilename } from "./get-filename";
|
|
27
|
+
import { normalizePath } from "./normalize-path";
|
|
28
|
+
import { prependHTTPS } from "./prepend-https";
|
|
29
|
+
export {
|
|
30
|
+
addQueryArgs,
|
|
31
|
+
buildQueryString,
|
|
32
|
+
cleanForSlug,
|
|
33
|
+
filterURLForDisplay,
|
|
34
|
+
getAuthority,
|
|
35
|
+
getFilename,
|
|
36
|
+
getFragment,
|
|
37
|
+
getPath,
|
|
38
|
+
getPathAndQueryString,
|
|
39
|
+
getProtocol,
|
|
40
|
+
getQueryArg,
|
|
41
|
+
getQueryArgs,
|
|
42
|
+
getQueryString,
|
|
43
|
+
hasQueryArg,
|
|
44
|
+
isEmail,
|
|
45
|
+
isPhoneNumber,
|
|
46
|
+
isURL,
|
|
47
|
+
isValidAuthority,
|
|
48
|
+
isValidFragment,
|
|
49
|
+
isValidPath,
|
|
50
|
+
isValidProtocol,
|
|
51
|
+
isValidQueryString,
|
|
52
|
+
normalizePath,
|
|
53
|
+
prependHTTP,
|
|
54
|
+
prependHTTPS,
|
|
55
|
+
removeQueryArgs,
|
|
56
|
+
safeDecodeURI,
|
|
57
|
+
safeDecodeURIComponent
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { isURL } from './is-url';\nexport { isEmail } from './is-email';\nexport { isPhoneNumber } from './is-phone-number';\nexport { getProtocol } from './get-protocol';\nexport { isValidProtocol } from './is-valid-protocol';\nexport { getAuthority } from './get-authority';\nexport { isValidAuthority } from './is-valid-authority';\nexport { getPath } from './get-path';\nexport { isValidPath } from './is-valid-path';\nexport { getQueryString } from './get-query-string';\nexport { buildQueryString } from './build-query-string';\nexport { isValidQueryString } from './is-valid-query-string';\nexport { getPathAndQueryString } from './get-path-and-query-string';\nexport { getFragment } from './get-fragment';\nexport { isValidFragment } from './is-valid-fragment';\nexport { addQueryArgs } from './add-query-args';\nexport { getQueryArg } from './get-query-arg';\nexport { getQueryArgs } from './get-query-args';\nexport { hasQueryArg } from './has-query-arg';\nexport { removeQueryArgs } from './remove-query-args';\nexport { prependHTTP } from './prepend-http';\nexport { safeDecodeURI } from './safe-decode-uri';\nexport { safeDecodeURIComponent } from './safe-decode-uri-component';\nexport { filterURLForDisplay } from './filter-url-for-display';\nexport { cleanForSlug } from './clean-for-slug';\nexport { getFilename } from './get-filename';\nexport { normalizePath } from './normalize-path';\nexport { prependHTTPS } from './prepend-https';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/is-email.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
const EMAIL_REGEXP = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Determines whether the given string looks like an email.
|
|
5
|
-
*
|
|
6
|
-
* @param email The string to scrutinise.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```js
|
|
10
|
-
* const isEmail = isEmail( 'hello@wordpress.org' ); // true
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @return Whether or not it looks like an email.
|
|
14
|
-
*/
|
|
15
|
-
export function isEmail(email) {
|
|
2
|
+
function isEmail(email) {
|
|
16
3
|
return EMAIL_REGEXP.test(email);
|
|
17
4
|
}
|
|
18
|
-
|
|
5
|
+
export {
|
|
6
|
+
isEmail
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=is-email.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-email.ts"],
|
|
4
|
+
"sourcesContent": ["const EMAIL_REGEXP =\n\t/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\\.[a-z]{2,63}$/i;\n\n/**\n * Determines whether the given string looks like an email.\n *\n * @param email The string to scrutinise.\n *\n * @example\n * ```js\n * const isEmail = isEmail( 'hello@wordpress.org' ); // true\n * ```\n *\n * @return Whether or not it looks like an email.\n */\nexport function isEmail( email: string ): boolean {\n\treturn EMAIL_REGEXP.test( email );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,MAAM,eACL;AAcM,SAAS,QAAS,OAAyB;AACjD,SAAO,aAAa,KAAM,KAAM;AACjC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
const PHONE_REGEXP = /^(tel:)?(\+)?\d{6,15}$/;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Determines whether the given string looks like a phone number.
|
|
5
|
-
*
|
|
6
|
-
* @param phoneNumber The string to scrutinize.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```js
|
|
10
|
-
* const isPhoneNumber = isPhoneNumber('+1 (555) 123-4567'); // true
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @return Whether or not it looks like a phone number.
|
|
14
|
-
*/
|
|
15
|
-
export function isPhoneNumber(phoneNumber) {
|
|
16
|
-
// Remove any separator from phone number.
|
|
17
|
-
phoneNumber = phoneNumber.replace(/[-.() ]/g, '');
|
|
2
|
+
function isPhoneNumber(phoneNumber) {
|
|
3
|
+
phoneNumber = phoneNumber.replace(/[-.() ]/g, "");
|
|
18
4
|
return PHONE_REGEXP.test(phoneNumber);
|
|
19
5
|
}
|
|
20
|
-
|
|
6
|
+
export {
|
|
7
|
+
isPhoneNumber
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=is-phone-number.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-phone-number.ts"],
|
|
4
|
+
"sourcesContent": ["const PHONE_REGEXP = /^(tel:)?(\\+)?\\d{6,15}$/;\n\n/**\n * Determines whether the given string looks like a phone number.\n *\n * @param phoneNumber The string to scrutinize.\n *\n * @example\n * ```js\n * const isPhoneNumber = isPhoneNumber('+1 (555) 123-4567'); // true\n * ```\n *\n * @return Whether or not it looks like a phone number.\n */\nexport function isPhoneNumber( phoneNumber: string ): boolean {\n\t// Remove any separator from phone number.\n\tphoneNumber = phoneNumber.replace( /[-.() ]/g, '' );\n\treturn PHONE_REGEXP.test( phoneNumber );\n}\n"],
|
|
5
|
+
"mappings": "AAAA,MAAM,eAAe;AAcd,SAAS,cAAe,aAA+B;AAE7D,gBAAc,YAAY,QAAS,YAAY,EAAG;AAClD,SAAO,aAAa,KAAM,WAAY;AACvC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/is-url.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Determines whether the given string looks like a URL.
|
|
4
|
-
*
|
|
5
|
-
* @param url The string to scrutinise.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* const isURL = isURL( 'https://wordpress.org' ); // true
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @see https://url.spec.whatwg.org/
|
|
13
|
-
* @see https://url.spec.whatwg.org/#valid-url-string
|
|
14
|
-
*
|
|
15
|
-
* @return Whether or not it looks like a URL.
|
|
16
|
-
*/
|
|
17
|
-
export function isURL(url) {
|
|
18
|
-
// A URL can be considered value if the `URL` constructor is able to parse
|
|
19
|
-
// it. The constructor throws an error for an invalid URL.
|
|
1
|
+
function isURL(url) {
|
|
20
2
|
try {
|
|
21
3
|
new URL(url);
|
|
22
4
|
return true;
|
|
@@ -24,4 +6,7 @@ export function isURL(url) {
|
|
|
24
6
|
return false;
|
|
25
7
|
}
|
|
26
8
|
}
|
|
27
|
-
|
|
9
|
+
export {
|
|
10
|
+
isURL
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=is-url.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-url.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Determines whether the given string looks like a URL.\n *\n * @param url The string to scrutinise.\n *\n * @example\n * ```js\n * const isURL = isURL( 'https://wordpress.org' ); // true\n * ```\n *\n * @see https://url.spec.whatwg.org/\n * @see https://url.spec.whatwg.org/#valid-url-string\n *\n * @return Whether or not it looks like a URL.\n */\nexport function isURL( url: string ): boolean {\n\t// A URL can be considered value if the `URL` constructor is able to parse\n\t// it. The constructor throws an error for an invalid URL.\n\ttry {\n\t\tnew URL( url );\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAeO,SAAS,MAAO,KAAuB;AAG7C,MAAI;AACH,QAAI,IAAK,GAAI;AACb,WAAO;AAAA,EACR,QAAQ;AACP,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Checks for invalid characters within the provided authority.
|
|
3
|
-
*
|
|
4
|
-
* @param authority A string containing the URL authority.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const isValid = isValidAuthority( 'wordpress.org' ); // true
|
|
9
|
-
* const isNotValid = isValidAuthority( 'wordpress#org' ); // false
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return True if the argument contains a valid authority.
|
|
13
|
-
*/
|
|
14
|
-
export function isValidAuthority(authority) {
|
|
1
|
+
function isValidAuthority(authority) {
|
|
15
2
|
if (!authority) {
|
|
16
3
|
return false;
|
|
17
4
|
}
|
|
18
5
|
return /^[^\s#?]+$/.test(authority);
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
isValidAuthority
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=is-valid-authority.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-valid-authority.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Checks for invalid characters within the provided authority.\n *\n * @param authority A string containing the URL authority.\n *\n * @example\n * ```js\n * const isValid = isValidAuthority( 'wordpress.org' ); // true\n * const isNotValid = isValidAuthority( 'wordpress#org' ); // false\n * ```\n *\n * @return True if the argument contains a valid authority.\n */\nexport function isValidAuthority( authority: string ): boolean {\n\tif ( ! authority ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?]+$/.test( authority );\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,iBAAkB,WAA6B;AAC9D,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AACA,SAAO,aAAa,KAAM,SAAU;AACrC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Checks for invalid characters within the provided fragment.
|
|
3
|
-
*
|
|
4
|
-
* @param fragment The url fragment.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const isValid = isValidFragment( '#valid-fragment' ); // true
|
|
9
|
-
* const isNotValid = isValidFragment( '#invalid-#fragment' ); // false
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return True if the argument contains a valid fragment.
|
|
13
|
-
*/
|
|
14
|
-
export function isValidFragment(fragment) {
|
|
1
|
+
function isValidFragment(fragment) {
|
|
15
2
|
if (!fragment) {
|
|
16
3
|
return false;
|
|
17
4
|
}
|
|
18
5
|
return /^#[^\s#?\/]*$/.test(fragment);
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
isValidFragment
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=is-valid-fragment.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-valid-fragment.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Checks for invalid characters within the provided fragment.\n *\n * @param fragment The url fragment.\n *\n * @example\n * ```js\n * const isValid = isValidFragment( '#valid-fragment' ); // true\n * const isNotValid = isValidFragment( '#invalid-#fragment' ); // false\n * ```\n *\n * @return True if the argument contains a valid fragment.\n */\nexport function isValidFragment( fragment: string ): boolean {\n\tif ( ! fragment ) {\n\t\treturn false;\n\t}\n\treturn /^#[^\\s#?\\/]*$/.test( fragment );\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,gBAAiB,UAA4B;AAC5D,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AACA,SAAO,gBAAgB,KAAM,QAAS;AACvC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|