@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
|
-
* Checks for invalid characters within the provided path.
|
|
3
|
-
*
|
|
4
|
-
* @param path The URL path.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const isValid = isValidPath( 'test/path/' ); // true
|
|
9
|
-
* const isNotValid = isValidPath( '/invalid?test/path/' ); // false
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return True if the argument contains a valid path
|
|
13
|
-
*/
|
|
14
|
-
export function isValidPath(path) {
|
|
1
|
+
function isValidPath(path) {
|
|
15
2
|
if (!path) {
|
|
16
3
|
return false;
|
|
17
4
|
}
|
|
18
5
|
return /^[^\s#?]+$/.test(path);
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
isValidPath
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=is-valid-path.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-valid-path.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Checks for invalid characters within the provided path.\n *\n * @param path The URL path.\n *\n * @example\n * ```js\n * const isValid = isValidPath( 'test/path/' ); // true\n * const isNotValid = isValidPath( '/invalid?test/path/' ); // false\n * ```\n *\n * @return True if the argument contains a valid path\n */\nexport function isValidPath( path: string ): boolean {\n\tif ( ! path ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?]+$/.test( path );\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,YAAa,MAAwB;AACpD,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AACA,SAAO,aAAa,KAAM,IAAK;AAChC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Tests if a url protocol is valid.
|
|
3
|
-
*
|
|
4
|
-
* @param protocol The url protocol.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const isValid = isValidProtocol( 'https:' ); // true
|
|
9
|
-
* const isNotValid = isValidProtocol( 'https :' ); // false
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return True if the argument is a valid protocol (e.g. http:, tel:).
|
|
13
|
-
*/
|
|
14
|
-
export function isValidProtocol(protocol) {
|
|
1
|
+
function isValidProtocol(protocol) {
|
|
15
2
|
if (!protocol) {
|
|
16
3
|
return false;
|
|
17
4
|
}
|
|
18
5
|
return /^[a-z\-.\+]+[0-9]*:$/i.test(protocol);
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
isValidProtocol
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=is-valid-protocol.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-valid-protocol.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Tests if a url protocol is valid.\n *\n * @param protocol The url protocol.\n *\n * @example\n * ```js\n * const isValid = isValidProtocol( 'https:' ); // true\n * const isNotValid = isValidProtocol( 'https :' ); // false\n * ```\n *\n * @return True if the argument is a valid protocol (e.g. http:, tel:).\n */\nexport function isValidProtocol( protocol: string ): boolean {\n\tif ( ! protocol ) {\n\t\treturn false;\n\t}\n\treturn /^[a-z\\-.\\+]+[0-9]*:$/i.test( protocol );\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,gBAAiB,UAA4B;AAC5D,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AACA,SAAO,wBAAwB,KAAM,QAAS;AAC/C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Checks for invalid characters within the provided query string.
|
|
3
|
-
*
|
|
4
|
-
* @param queryString The query string.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const isValid = isValidQueryString( 'query=true&another=false' ); // true
|
|
9
|
-
* const isNotValid = isValidQueryString( 'query=true?another=false' ); // false
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return True if the argument contains a valid query string.
|
|
13
|
-
*/
|
|
14
|
-
export function isValidQueryString(queryString) {
|
|
1
|
+
function isValidQueryString(queryString) {
|
|
15
2
|
if (!queryString) {
|
|
16
3
|
return false;
|
|
17
4
|
}
|
|
18
5
|
return /^[^\s#?\/]+$/.test(queryString);
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
isValidQueryString
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=is-valid-query-string.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/is-valid-query-string.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Checks for invalid characters within the provided query string.\n *\n * @param queryString The query string.\n *\n * @example\n * ```js\n * const isValid = isValidQueryString( 'query=true&another=false' ); // true\n * const isNotValid = isValidQueryString( 'query=true?another=false' ); // false\n * ```\n *\n * @return True if the argument contains a valid query string.\n */\nexport function isValidQueryString( queryString: string ): boolean {\n\tif ( ! queryString ) {\n\t\treturn false;\n\t}\n\treturn /^[^\\s#?\\/]+$/.test( queryString );\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,mBAAoB,aAA+B;AAClE,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AACA,SAAO,eAAe,KAAM,WAAY;AACzC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* will be treated as identical, regardless of order they appear in the original
|
|
4
|
-
* text.
|
|
5
|
-
*
|
|
6
|
-
* @param path Original path.
|
|
7
|
-
*
|
|
8
|
-
* @return Normalized path.
|
|
9
|
-
*/
|
|
10
|
-
export function normalizePath(path) {
|
|
11
|
-
const split = path.split('?');
|
|
1
|
+
function normalizePath(path) {
|
|
2
|
+
const split = path.split("?");
|
|
12
3
|
const query = split[1];
|
|
13
4
|
const base = split[0];
|
|
14
5
|
if (!query) {
|
|
15
6
|
return base;
|
|
16
7
|
}
|
|
17
|
-
|
|
18
|
-
// 'b=1%2C2&c=2&a=5'
|
|
19
|
-
return base + '?' + query
|
|
20
|
-
// [ 'b=1%2C2', 'c=2', 'a=5' ]
|
|
21
|
-
.split('&')
|
|
22
|
-
// [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]
|
|
23
|
-
.map(entry => entry.split('='))
|
|
24
|
-
// [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]
|
|
25
|
-
.map(pair => pair.map(decodeURIComponent))
|
|
26
|
-
// [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]
|
|
27
|
-
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
28
|
-
// [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]
|
|
29
|
-
.map(pair => pair.map(encodeURIComponent))
|
|
30
|
-
// [ 'a=5', 'b=1%2C2', 'c=2' ]
|
|
31
|
-
.map(pair => pair.join('='))
|
|
32
|
-
// 'a=5&b=1%2C2&c=2'
|
|
33
|
-
.join('&');
|
|
8
|
+
return base + "?" + query.split("&").map((entry) => entry.split("=")).map((pair) => pair.map(decodeURIComponent)).sort((a, b) => a[0].localeCompare(b[0])).map((pair) => pair.map(encodeURIComponent)).map((pair) => pair.join("=")).join("&");
|
|
34
9
|
}
|
|
35
|
-
|
|
10
|
+
export {
|
|
11
|
+
normalizePath
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=normalize-path.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/normalize-path.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Given a path, returns a normalized path where equal query parameter values\n * will be treated as identical, regardless of order they appear in the original\n * text.\n *\n * @param path Original path.\n *\n * @return Normalized path.\n */\nexport function normalizePath( path: string ): string {\n\tconst split = path.split( '?' );\n\tconst query = split[ 1 ];\n\tconst base = split[ 0 ];\n\tif ( ! query ) {\n\t\treturn base;\n\t}\n\n\t// 'b=1%2C2&c=2&a=5'\n\treturn (\n\t\tbase +\n\t\t'?' +\n\t\tquery\n\t\t\t// [ 'b=1%2C2', 'c=2', 'a=5' ]\n\t\t\t.split( '&' )\n\t\t\t// [ [ 'b, '1%2C2' ], [ 'c', '2' ], [ 'a', '5' ] ]\n\t\t\t.map( ( entry ) => entry.split( '=' ) )\n\t\t\t// [ [ 'b', '1,2' ], [ 'c', '2' ], [ 'a', '5' ] ]\n\t\t\t.map( ( pair ) => pair.map( decodeURIComponent ) )\n\t\t\t// [ [ 'a', '5' ], [ 'b, '1,2' ], [ 'c', '2' ] ]\n\t\t\t.sort( ( a, b ) => a[ 0 ].localeCompare( b[ 0 ] ) )\n\t\t\t// [ [ 'a', '5' ], [ 'b, '1%2C2' ], [ 'c', '2' ] ]\n\t\t\t.map( ( pair ) => pair.map( encodeURIComponent ) )\n\t\t\t// [ 'a=5', 'b=1%2C2', 'c=2' ]\n\t\t\t.map( ( pair ) => pair.join( '=' ) )\n\t\t\t// 'a=5&b=1%2C2&c=2'\n\t\t\t.join( '&' )\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AASO,SAAS,cAAe,MAAuB;AACrD,QAAM,QAAQ,KAAK,MAAO,GAAI;AAC9B,QAAM,QAAQ,MAAO,CAAE;AACvB,QAAM,OAAO,MAAO,CAAE;AACtB,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAGA,SACC,OACA,MACA,MAEE,MAAO,GAAI,EAEX,IAAK,CAAE,UAAW,MAAM,MAAO,GAAI,CAAE,EAErC,IAAK,CAAE,SAAU,KAAK,IAAK,kBAAmB,CAAE,EAEhD,KAAM,CAAE,GAAG,MAAO,EAAG,CAAE,EAAE,cAAe,EAAG,CAAE,CAAE,CAAE,EAEjD,IAAK,CAAE,SAAU,KAAK,IAAK,kBAAmB,CAAE,EAEhD,IAAK,CAAE,SAAU,KAAK,KAAM,GAAI,CAAE,EAElC,KAAM,GAAI;AAEd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isEmail } from './is-email';
|
|
1
|
+
import { isEmail } from "./is-email";
|
|
5
2
|
const USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\?|\.|\/)/i;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Prepends "http://" to a url, if it looks like something that is meant to be a TLD.
|
|
9
|
-
*
|
|
10
|
-
* @param url The URL to test.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```js
|
|
14
|
-
* const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @return The updated URL.
|
|
18
|
-
*/
|
|
19
|
-
export function prependHTTP(url) {
|
|
3
|
+
function prependHTTP(url) {
|
|
20
4
|
if (!url) {
|
|
21
5
|
return url;
|
|
22
6
|
}
|
|
23
7
|
url = url.trim();
|
|
24
8
|
if (!USABLE_HREF_REGEXP.test(url) && !isEmail(url)) {
|
|
25
|
-
return
|
|
9
|
+
return "http://" + url;
|
|
26
10
|
}
|
|
27
11
|
return url;
|
|
28
12
|
}
|
|
29
|
-
|
|
13
|
+
export {
|
|
14
|
+
prependHTTP
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=prepend-http.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/prepend-http.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { isEmail } from './is-email';\n\nconst USABLE_HREF_REGEXP = /^(?:[a-z]+:|#|\\?|\\.|\\/)/i;\n\n/**\n * Prepends \"http://\" to a url, if it looks like something that is meant to be a TLD.\n *\n * @param url The URL to test.\n *\n * @example\n * ```js\n * const actualURL = prependHTTP( 'wordpress.org' ); // http://wordpress.org\n * ```\n *\n * @return The updated URL.\n */\nexport function prependHTTP( url: string ): string {\n\tif ( ! url ) {\n\t\treturn url;\n\t}\n\n\turl = url.trim();\n\tif ( ! USABLE_HREF_REGEXP.test( url ) && ! isEmail( url ) ) {\n\t\treturn 'http://' + url;\n\t}\n\n\treturn url;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,eAAe;AAExB,MAAM,qBAAqB;AAcpB,SAAS,YAAa,KAAsB;AAClD,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAEA,QAAM,IAAI,KAAK;AACf,MAAK,CAAE,mBAAmB,KAAM,GAAI,KAAK,CAAE,QAAS,GAAI,GAAI;AAC3D,WAAO,YAAY;AAAA,EACpB;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,32 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { prependHTTP } from './prepend-http';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Prepends "https://" to a url, if it looks like something that is meant to be a TLD.
|
|
8
|
-
*
|
|
9
|
-
* Note: this will not replace "http://" with "https://".
|
|
10
|
-
*
|
|
11
|
-
* @param url The URL to test.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```js
|
|
15
|
-
* const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @return The updated URL.
|
|
19
|
-
*/
|
|
20
|
-
export function prependHTTPS(url) {
|
|
1
|
+
import { prependHTTP } from "./prepend-http";
|
|
2
|
+
function prependHTTPS(url) {
|
|
21
3
|
if (!url) {
|
|
22
4
|
return url;
|
|
23
5
|
}
|
|
24
|
-
|
|
25
|
-
// If url starts with http://, return it as is.
|
|
26
|
-
if (url.startsWith('http://')) {
|
|
6
|
+
if (url.startsWith("http://")) {
|
|
27
7
|
return url;
|
|
28
8
|
}
|
|
29
9
|
url = prependHTTP(url);
|
|
30
|
-
return url.replace(/^http:/,
|
|
10
|
+
return url.replace(/^http:/, "https:");
|
|
31
11
|
}
|
|
32
|
-
|
|
12
|
+
export {
|
|
13
|
+
prependHTTPS
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=prepend-https.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/prepend-https.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { prependHTTP } from './prepend-http';\n\n/**\n * Prepends \"https://\" to a url, if it looks like something that is meant to be a TLD.\n *\n * Note: this will not replace \"http://\" with \"https://\".\n *\n * @param url The URL to test.\n *\n * @example\n * ```js\n * const actualURL = prependHTTPS( 'wordpress.org' ); // https://wordpress.org\n * ```\n *\n * @return The updated URL.\n */\nexport function prependHTTPS( url: string ): string {\n\tif ( ! url ) {\n\t\treturn url;\n\t}\n\n\t// If url starts with http://, return it as is.\n\tif ( url.startsWith( 'http://' ) ) {\n\t\treturn url;\n\t}\n\n\turl = prependHTTP( url );\n\n\treturn url.replace( /^http:/, 'https:' );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,mBAAmB;AAgBrB,SAAS,aAAc,KAAsB;AACnD,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAK,IAAI,WAAY,SAAU,GAAI;AAClC,WAAO;AAAA,EACR;AAEA,QAAM,YAAa,GAAI;AAEvB,SAAO,IAAI,QAAS,UAAU,QAAS;AACxC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Removes arguments from the query string of the url
|
|
9
|
-
*
|
|
10
|
-
* @param url URL.
|
|
11
|
-
* @param args Query Args.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```js
|
|
15
|
-
* const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @return Updated URL.
|
|
19
|
-
*/
|
|
20
|
-
export function removeQueryArgs(url, ...args) {
|
|
21
|
-
const fragment = url.replace(/^[^#]*/, '');
|
|
22
|
-
url = url.replace(/#.*/, '');
|
|
23
|
-
const queryStringIndex = url.indexOf('?');
|
|
1
|
+
import { getQueryArgs } from "./get-query-args";
|
|
2
|
+
import { buildQueryString } from "./build-query-string";
|
|
3
|
+
function removeQueryArgs(url, ...args) {
|
|
4
|
+
const fragment = url.replace(/^[^#]*/, "");
|
|
5
|
+
url = url.replace(/#.*/, "");
|
|
6
|
+
const queryStringIndex = url.indexOf("?");
|
|
24
7
|
if (queryStringIndex === -1) {
|
|
25
8
|
return url + fragment;
|
|
26
9
|
}
|
|
27
10
|
const query = getQueryArgs(url);
|
|
28
11
|
const baseURL = url.substr(0, queryStringIndex);
|
|
29
|
-
args.forEach(arg => delete query[arg]);
|
|
12
|
+
args.forEach((arg) => delete query[arg]);
|
|
30
13
|
const queryString = buildQueryString(query);
|
|
31
|
-
const updatedUrl = queryString ? baseURL +
|
|
14
|
+
const updatedUrl = queryString ? baseURL + "?" + queryString : baseURL;
|
|
32
15
|
return updatedUrl + fragment;
|
|
33
16
|
}
|
|
34
|
-
|
|
17
|
+
export {
|
|
18
|
+
removeQueryArgs
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=remove-query-args.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/remove-query-args.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\n\n/**\n * Removes arguments from the query string of the url\n *\n * @param url URL.\n * @param args Query Args.\n *\n * @example\n * ```js\n * const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar\n * ```\n *\n * @return Updated URL.\n */\nexport function removeQueryArgs( url: string, ...args: string[] ): string {\n\tconst fragment = url.replace( /^[^#]*/, '' );\n\turl = url.replace( /#.*/, '' );\n\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex === -1 ) {\n\t\treturn url + fragment;\n\t}\n\n\tconst query = getQueryArgs( url );\n\tconst baseURL = url.substr( 0, queryStringIndex );\n\targs.forEach( ( arg ) => delete query[ arg ] );\n\tconst queryString = buildQueryString( query );\n\tconst updatedUrl = queryString ? baseURL + '?' + queryString : baseURL;\n\treturn updatedUrl + fragment;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAe1B,SAAS,gBAAiB,QAAgB,MAAyB;AACzE,QAAM,WAAW,IAAI,QAAS,UAAU,EAAG;AAC3C,QAAM,IAAI,QAAS,OAAO,EAAG;AAE7B,QAAM,mBAAmB,IAAI,QAAS,GAAI;AAC1C,MAAK,qBAAqB,IAAK;AAC9B,WAAO,MAAM;AAAA,EACd;AAEA,QAAM,QAAQ,aAAc,GAAI;AAChC,QAAM,UAAU,IAAI,OAAQ,GAAG,gBAAiB;AAChD,OAAK,QAAS,CAAE,QAAS,OAAO,MAAO,GAAI,CAAE;AAC7C,QAAM,cAAc,iBAAkB,KAAM;AAC5C,QAAM,aAAa,cAAc,UAAU,MAAM,cAAc;AAC/D,SAAO,aAAa;AACrB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
|
|
3
|
-
* `decodeURIComponent` throws an error.
|
|
4
|
-
*
|
|
5
|
-
* @param uriComponent URI component to decode.
|
|
6
|
-
*
|
|
7
|
-
* @return Decoded URI component if possible.
|
|
8
|
-
*/
|
|
9
|
-
export function safeDecodeURIComponent(uriComponent) {
|
|
1
|
+
function safeDecodeURIComponent(uriComponent) {
|
|
10
2
|
try {
|
|
11
3
|
return decodeURIComponent(uriComponent);
|
|
12
4
|
} catch (uriComponentError) {
|
|
13
5
|
return uriComponent;
|
|
14
6
|
}
|
|
15
7
|
}
|
|
16
|
-
|
|
8
|
+
export {
|
|
9
|
+
safeDecodeURIComponent
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=safe-decode-uri-component.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/safe-decode-uri-component.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if\n * `decodeURIComponent` throws an error.\n *\n * @param uriComponent URI component to decode.\n *\n * @return Decoded URI component if possible.\n */\nexport function safeDecodeURIComponent( uriComponent: string ): string {\n\ttry {\n\t\treturn decodeURIComponent( uriComponent );\n\t} catch ( uriComponentError ) {\n\t\treturn uriComponent;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAQO,SAAS,uBAAwB,cAA+B;AACtE,MAAI;AACH,WAAO,mBAAoB,YAAa;AAAA,EACzC,SAAU,mBAAoB;AAC7B,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
|
|
3
|
-
* `decodeURI` throws an error.
|
|
4
|
-
*
|
|
5
|
-
* @param uri URI to decode.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return Decoded URI if possible.
|
|
13
|
-
*/
|
|
14
|
-
export function safeDecodeURI(uri) {
|
|
1
|
+
function safeDecodeURI(uri) {
|
|
15
2
|
try {
|
|
16
3
|
return decodeURI(uri);
|
|
17
4
|
} catch (uriError) {
|
|
18
5
|
return uri;
|
|
19
6
|
}
|
|
20
7
|
}
|
|
21
|
-
|
|
8
|
+
export {
|
|
9
|
+
safeDecodeURI
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=safe-decode-uri.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/safe-decode-uri.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if\n * `decodeURI` throws an error.\n *\n * @param uri URI to decode.\n *\n * @example\n * ```js\n * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'\n * ```\n *\n * @return Decoded URI if possible.\n */\nexport function safeDecodeURI( uri: string ): string {\n\ttry {\n\t\treturn decodeURI( uri );\n\t} catch ( uriError ) {\n\t\treturn uri;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,cAAe,KAAsB;AACpD,MAAI;AACH,WAAO,UAAW,GAAI;AAAA,EACvB,SAAU,UAAW;AACpB,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/url",
|
|
3
|
-
"version": "4.32.0",
|
|
3
|
+
"version": "4.32.1-next.ff1cebbba.0",
|
|
4
4
|
"description": "WordPress URL utilities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -24,16 +24,23 @@
|
|
|
24
24
|
},
|
|
25
25
|
"main": "build/index.js",
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./build-types/index.d.ts",
|
|
30
|
+
"import": "./build-module/index.js",
|
|
31
|
+
"require": "./build/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
27
35
|
"react-native": "src/index",
|
|
28
36
|
"wpScript": true,
|
|
29
37
|
"types": "build-types",
|
|
30
38
|
"sideEffects": false,
|
|
31
39
|
"dependencies": {
|
|
32
|
-
"@babel/runtime": "7.25.7",
|
|
33
40
|
"remove-accents": "^0.5.0"
|
|
34
41
|
},
|
|
35
42
|
"publishConfig": {
|
|
36
43
|
"access": "public"
|
|
37
44
|
},
|
|
38
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c5b659710aff01d40d2eb97b211eb2cec9c07d3b"
|
|
39
46
|
}
|