@wordpress/url 4.31.1-next.f56bd8138.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/CHANGELOG.md +2 -0
- 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,17 +1,26 @@
|
|
|
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 safe_decode_uri_component_exports = {};
|
|
20
|
+
__export(safe_decode_uri_component_exports, {
|
|
21
|
+
safeDecodeURIComponent: () => safeDecodeURIComponent
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
/**
|
|
8
|
-
* Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
|
|
9
|
-
* `decodeURIComponent` throws an error.
|
|
10
|
-
*
|
|
11
|
-
* @param uriComponent URI component to decode.
|
|
12
|
-
*
|
|
13
|
-
* @return Decoded URI component if possible.
|
|
14
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(safe_decode_uri_component_exports);
|
|
15
24
|
function safeDecodeURIComponent(uriComponent) {
|
|
16
25
|
try {
|
|
17
26
|
return decodeURIComponent(uriComponent);
|
|
@@ -19,4 +28,8 @@ function safeDecodeURIComponent(uriComponent) {
|
|
|
19
28
|
return uriComponent;
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
|
-
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
safeDecodeURIComponent
|
|
34
|
+
});
|
|
35
|
+
//# 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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,uBAAwB,cAA+B;AACtE,MAAI;AACH,WAAO,mBAAoB,YAAa;AAAA,EACzC,SAAU,mBAAoB;AAC7B,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/safe-decode-uri.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
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 safe_decode_uri_exports = {};
|
|
20
|
+
__export(safe_decode_uri_exports, {
|
|
21
|
+
safeDecodeURI: () => safeDecodeURI
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
/**
|
|
8
|
-
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
|
|
9
|
-
* `decodeURI` throws an error.
|
|
10
|
-
*
|
|
11
|
-
* @param uri URI to decode.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```js
|
|
15
|
-
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @return Decoded URI if possible.
|
|
19
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(safe_decode_uri_exports);
|
|
20
24
|
function safeDecodeURI(uri) {
|
|
21
25
|
try {
|
|
22
26
|
return decodeURI(uri);
|
|
@@ -24,4 +28,8 @@ function safeDecodeURI(uri) {
|
|
|
24
28
|
return uri;
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
|
-
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
safeDecodeURI
|
|
34
|
+
});
|
|
35
|
+
//# 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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,cAAe,KAAsB;AACpD,MAAI;AACH,WAAO,UAAW,GAAI;AAAA,EACvB,SAAU,UAAW;AACpB,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,43 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { buildQueryString } from './build-query-string';
|
|
6
|
-
import { getFragment } from './get-fragment';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Appends arguments as querystring to the provided URL. If the URL already
|
|
10
|
-
* includes query arguments, the arguments are merged with (and take precedent
|
|
11
|
-
* over) the existing set.
|
|
12
|
-
*
|
|
13
|
-
* @param url URL to which arguments should be appended. If omitted,
|
|
14
|
-
* only the resulting querystring is returned.
|
|
15
|
-
* @param args Query arguments to apply to URL.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```js
|
|
19
|
-
* const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @return URL with arguments applied.
|
|
23
|
-
*/
|
|
24
|
-
export function addQueryArgs(url = '', args) {
|
|
25
|
-
// If no arguments are to be appended, return original URL.
|
|
1
|
+
import { getQueryArgs } from "./get-query-args";
|
|
2
|
+
import { buildQueryString } from "./build-query-string";
|
|
3
|
+
import { getFragment } from "./get-fragment";
|
|
4
|
+
function addQueryArgs(url = "", args) {
|
|
26
5
|
if (!args || !Object.keys(args).length) {
|
|
27
6
|
return url;
|
|
28
7
|
}
|
|
29
|
-
const fragment = getFragment(url) ||
|
|
30
|
-
let baseUrl = url.replace(fragment,
|
|
31
|
-
|
|
32
|
-
// Determine whether URL already had query arguments.
|
|
33
|
-
const queryStringIndex = url.indexOf('?');
|
|
8
|
+
const fragment = getFragment(url) || "";
|
|
9
|
+
let baseUrl = url.replace(fragment, "");
|
|
10
|
+
const queryStringIndex = url.indexOf("?");
|
|
34
11
|
if (queryStringIndex !== -1) {
|
|
35
|
-
// Merge into existing query arguments.
|
|
36
12
|
args = Object.assign(getQueryArgs(url), args);
|
|
37
|
-
|
|
38
|
-
// Change working base URL to omit previous query arguments.
|
|
39
13
|
baseUrl = baseUrl.substr(0, queryStringIndex);
|
|
40
14
|
}
|
|
41
|
-
return baseUrl +
|
|
15
|
+
return baseUrl + "?" + buildQueryString(args) + fragment;
|
|
42
16
|
}
|
|
43
|
-
|
|
17
|
+
export {
|
|
18
|
+
addQueryArgs
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=add-query-args.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/add-query-args.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\nimport { buildQueryString } from './build-query-string';\nimport { getFragment } from './get-fragment';\n\n/**\n * Appends arguments as querystring to the provided URL. If the URL already\n * includes query arguments, the arguments are merged with (and take precedent\n * over) the existing set.\n *\n * @param url URL to which arguments should be appended. If omitted,\n * only the resulting querystring is returned.\n * @param args Query arguments to apply to URL.\n *\n * @example\n * ```js\n * const newURL = addQueryArgs( 'https://google.com', { q: 'test' } ); // https://google.com/?q=test\n * ```\n *\n * @return URL with arguments applied.\n */\nexport function addQueryArgs(\n\turl: string = '',\n\targs?: Record< string, unknown >\n): string {\n\t// If no arguments are to be appended, return original URL.\n\tif ( ! args || ! Object.keys( args ).length ) {\n\t\treturn url;\n\t}\n\n\tconst fragment = getFragment( url ) || '';\n\tlet baseUrl = url.replace( fragment, '' );\n\n\t// Determine whether URL already had query arguments.\n\tconst queryStringIndex = url.indexOf( '?' );\n\tif ( queryStringIndex !== -1 ) {\n\t\t// Merge into existing query arguments.\n\t\targs = Object.assign( getQueryArgs( url ), args );\n\n\t\t// Change working base URL to omit previous query arguments.\n\t\tbaseUrl = baseUrl.substr( 0, queryStringIndex );\n\t}\n\n\treturn baseUrl + '?' + buildQueryString( args ) + fragment;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAkBrB,SAAS,aACf,MAAc,IACd,MACS;AAET,MAAK,CAAE,QAAQ,CAAE,OAAO,KAAM,IAAK,EAAE,QAAS;AAC7C,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,YAAa,GAAI,KAAK;AACvC,MAAI,UAAU,IAAI,QAAS,UAAU,EAAG;AAGxC,QAAM,mBAAmB,IAAI,QAAS,GAAI;AAC1C,MAAK,qBAAqB,IAAK;AAE9B,WAAO,OAAO,OAAQ,aAAc,GAAI,GAAG,IAAK;AAGhD,cAAU,QAAQ,OAAQ,GAAG,gBAAiB;AAAA,EAC/C;AAEA,SAAO,UAAU,MAAM,iBAAkB,IAAK,IAAI;AACnD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,56 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* It is intended to behave equivalent as PHP's `http_build_query`, configured
|
|
5
|
-
* with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* const queryString = buildQueryString( {
|
|
10
|
-
* simple: 'is ok',
|
|
11
|
-
* arrays: [ 'are', 'fine', 'too' ],
|
|
12
|
-
* objects: {
|
|
13
|
-
* evenNested: {
|
|
14
|
-
* ok: 'yes',
|
|
15
|
-
* },
|
|
16
|
-
* },
|
|
17
|
-
* } );
|
|
18
|
-
* // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @param data Data to encode.
|
|
22
|
-
*
|
|
23
|
-
* @return Query string.
|
|
24
|
-
*/
|
|
25
|
-
export function buildQueryString(data) {
|
|
26
|
-
let string = '';
|
|
1
|
+
function buildQueryString(data) {
|
|
2
|
+
let string = "";
|
|
27
3
|
const stack = Object.entries(data);
|
|
28
4
|
let pair;
|
|
29
5
|
while (pair = stack.shift()) {
|
|
30
6
|
let [key, value] = pair;
|
|
31
|
-
|
|
32
|
-
// Support building deeply nested data, from array or object values.
|
|
33
7
|
const hasNestedData = Array.isArray(value) || value && value.constructor === Object;
|
|
34
8
|
if (hasNestedData) {
|
|
35
|
-
// Push array or object values onto the stack as composed of their
|
|
36
|
-
// original key and nested index or key, retaining order by a
|
|
37
|
-
// combination of Array#reverse and Array#unshift onto the stack.
|
|
38
9
|
const valuePairs = Object.entries(value).reverse();
|
|
39
10
|
for (const [member, memberValue] of valuePairs) {
|
|
40
11
|
stack.unshift([`${key}[${member}]`, memberValue]);
|
|
41
12
|
}
|
|
42
|
-
} else if (value !==
|
|
43
|
-
// Null is treated as special case, equivalent to empty string.
|
|
13
|
+
} else if (value !== void 0) {
|
|
44
14
|
if (value === null) {
|
|
45
|
-
value =
|
|
15
|
+
value = "";
|
|
46
16
|
}
|
|
47
|
-
string +=
|
|
17
|
+
string += "&" + [key, String(value)].map(encodeURIComponent).join("=");
|
|
48
18
|
}
|
|
49
19
|
}
|
|
50
|
-
|
|
51
|
-
// Loop will concatenate with leading `&`, but it's only expected for all
|
|
52
|
-
// but the first query parameter. This strips the leading `&`, while still
|
|
53
|
-
// accounting for the case that the string may in-fact be empty.
|
|
54
20
|
return string.substr(1);
|
|
55
21
|
}
|
|
56
|
-
|
|
22
|
+
export {
|
|
23
|
+
buildQueryString
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=build-query-string.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/build-query-string.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Generates URL-encoded query string using input query data.\n *\n * It is intended to behave equivalent as PHP's `http_build_query`, configured\n * with encoding type PHP_QUERY_RFC3986 (spaces as `%20`).\n *\n * @example\n * ```js\n * const queryString = buildQueryString( {\n * simple: 'is ok',\n * arrays: [ 'are', 'fine', 'too' ],\n * objects: {\n * evenNested: {\n * ok: 'yes',\n * },\n * },\n * } );\n * // \"simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes\"\n * ```\n *\n * @param data Data to encode.\n *\n * @return Query string.\n */\nexport function buildQueryString( data: Record< string, unknown > ): string {\n\tlet string = '';\n\n\tconst stack: Array< [ string, unknown ] > = Object.entries( data );\n\n\tlet pair;\n\twhile ( ( pair = stack.shift() ) ) {\n\t\tlet [ key, value ] = pair;\n\n\t\t// Support building deeply nested data, from array or object values.\n\t\tconst hasNestedData =\n\t\t\tArray.isArray( value ) || ( value && value.constructor === Object );\n\n\t\tif ( hasNestedData ) {\n\t\t\t// Push array or object values onto the stack as composed of their\n\t\t\t// original key and nested index or key, retaining order by a\n\t\t\t// combination of Array#reverse and Array#unshift onto the stack.\n\t\t\tconst valuePairs = Object.entries( value as object ).reverse();\n\t\t\tfor ( const [ member, memberValue ] of valuePairs ) {\n\t\t\t\tstack.unshift( [ `${ key }[${ member }]`, memberValue ] );\n\t\t\t}\n\t\t} else if ( value !== undefined ) {\n\t\t\t// Null is treated as special case, equivalent to empty string.\n\t\t\tif ( value === null ) {\n\t\t\t\tvalue = '';\n\t\t\t}\n\n\t\t\tstring +=\n\t\t\t\t'&' +\n\t\t\t\t[ key, String( value ) ].map( encodeURIComponent ).join( '=' );\n\t\t}\n\t}\n\n\t// Loop will concatenate with leading `&`, but it's only expected for all\n\t// but the first query parameter. This strips the leading `&`, while still\n\t// accounting for the case that the string may in-fact be empty.\n\treturn string.substr( 1 );\n}\n"],
|
|
5
|
+
"mappings": "AAwBO,SAAS,iBAAkB,MAA0C;AAC3E,MAAI,SAAS;AAEb,QAAM,QAAsC,OAAO,QAAS,IAAK;AAEjE,MAAI;AACJ,SAAU,OAAO,MAAM,MAAM,GAAM;AAClC,QAAI,CAAE,KAAK,KAAM,IAAI;AAGrB,UAAM,gBACL,MAAM,QAAS,KAAM,KAAO,SAAS,MAAM,gBAAgB;AAE5D,QAAK,eAAgB;AAIpB,YAAM,aAAa,OAAO,QAAS,KAAgB,EAAE,QAAQ;AAC7D,iBAAY,CAAE,QAAQ,WAAY,KAAK,YAAa;AACnD,cAAM,QAAS,CAAE,GAAI,GAAI,IAAK,MAAO,KAAK,WAAY,CAAE;AAAA,MACzD;AAAA,IACD,WAAY,UAAU,QAAY;AAEjC,UAAK,UAAU,MAAO;AACrB,gBAAQ;AAAA,MACT;AAEA,gBACC,MACA,CAAE,KAAK,OAAQ,KAAM,CAAE,EAAE,IAAK,kBAAmB,EAAE,KAAM,GAAI;AAAA,IAC/D;AAAA,EACD;AAKA,SAAO,OAAO,OAAQ,CAAE;AACzB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,42 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import removeAccents from 'remove-accents';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Performs some basic cleanup of a string for use as a post slug.
|
|
8
|
-
*
|
|
9
|
-
* This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but
|
|
10
|
-
* is only designed to approximate what the slug will be.
|
|
11
|
-
*
|
|
12
|
-
* Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin
|
|
13
|
-
* letters. Removes combining diacritical marks. Converts whitespace, periods,
|
|
14
|
-
* and forward slashes to hyphens. Removes any remaining non-word characters
|
|
15
|
-
* except hyphens. Converts remaining string to lowercase. It does not account
|
|
16
|
-
* for octets, HTML entities, or other encoded characters.
|
|
17
|
-
*
|
|
18
|
-
* @param string Title or slug to be processed.
|
|
19
|
-
*
|
|
20
|
-
* @return Processed string.
|
|
21
|
-
*/
|
|
22
|
-
export function cleanForSlug(string) {
|
|
1
|
+
import removeAccents from "remove-accents";
|
|
2
|
+
function cleanForSlug(string) {
|
|
23
3
|
if (!string) {
|
|
24
|
-
return
|
|
4
|
+
return "";
|
|
25
5
|
}
|
|
26
|
-
return removeAccents(string)
|
|
27
|
-
// Convert  , &ndash, and &mdash to hyphens.
|
|
28
|
-
.replace(/( |–|—)/g, '-')
|
|
29
|
-
// Convert each group of whitespace, periods, and forward slashes to a hyphen.
|
|
30
|
-
.replace(/[\s\./]+/g, '-')
|
|
31
|
-
// Remove all HTML entities.
|
|
32
|
-
.replace(/&\S+?;/g, '')
|
|
33
|
-
// Remove anything that's not a letter, number, underscore or hyphen.
|
|
34
|
-
.replace(/[^\p{L}\p{N}_-]+/gu, '')
|
|
35
|
-
// Convert to lowercase
|
|
36
|
-
.toLowerCase()
|
|
37
|
-
// Replace multiple hyphens with a single one.
|
|
38
|
-
.replace(/-+/g, '-')
|
|
39
|
-
// Remove any remaining leading or trailing hyphens.
|
|
40
|
-
.replace(/(^-+)|(-+$)/g, '');
|
|
6
|
+
return removeAccents(string).replace(/( |–|—)/g, "-").replace(/[\s\./]+/g, "-").replace(/&\S+?;/g, "").replace(/[^\p{L}\p{N}_-]+/gu, "").toLowerCase().replace(/-+/g, "-").replace(/(^-+)|(-+$)/g, "");
|
|
41
7
|
}
|
|
42
|
-
|
|
8
|
+
export {
|
|
9
|
+
cleanForSlug
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=clean-for-slug.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/clean-for-slug.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Performs some basic cleanup of a string for use as a post slug.\n *\n * This replicates some of what `sanitize_title_with_dashes()` does in WordPress core, but\n * is only designed to approximate what the slug will be.\n *\n * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin\n * letters. Removes combining diacritical marks. Converts whitespace, periods,\n * and forward slashes to hyphens. Removes any remaining non-word characters\n * except hyphens. Converts remaining string to lowercase. It does not account\n * for octets, HTML entities, or other encoded characters.\n *\n * @param string Title or slug to be processed.\n *\n * @return Processed string.\n */\nexport function cleanForSlug( string: string ): string {\n\tif ( ! string ) {\n\t\treturn '';\n\t}\n\treturn (\n\t\tremoveAccents( string )\n\t\t\t// Convert  , &ndash, and &mdash to hyphens.\n\t\t\t.replace( /( |–|—)/g, '-' )\n\t\t\t// Convert each group of whitespace, periods, and forward slashes to a hyphen.\n\t\t\t.replace( /[\\s\\./]+/g, '-' )\n\t\t\t// Remove all HTML entities.\n\t\t\t.replace( /&\\S+?;/g, '' )\n\t\t\t// Remove anything that's not a letter, number, underscore or hyphen.\n\t\t\t.replace( /[^\\p{L}\\p{N}_-]+/gu, '' )\n\t\t\t// Convert to lowercase\n\t\t\t.toLowerCase()\n\t\t\t// Replace multiple hyphens with a single one.\n\t\t\t.replace( /-+/g, '-' )\n\t\t\t// Remove any remaining leading or trailing hyphens.\n\t\t\t.replace( /(^-+)|(-+$)/g, '' )\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,mBAAmB;AAkBnB,SAAS,aAAc,QAAyB;AACtD,MAAK,CAAE,QAAS;AACf,WAAO;AAAA,EACR;AACA,SACC,cAAe,MAAO,EAEpB,QAAS,6BAA6B,GAAI,EAE1C,QAAS,aAAa,GAAI,EAE1B,QAAS,WAAW,EAAG,EAEvB,QAAS,sBAAsB,EAAG,EAElC,YAAY,EAEZ,QAAS,OAAO,GAAI,EAEpB,QAAS,gBAAgB,EAAG;AAEhC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,48 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
* Returns a URL for display.
|
|
3
|
-
*
|
|
4
|
-
* @param url Original URL.
|
|
5
|
-
* @param maxLength URL length.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
|
|
10
|
-
* const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @return Displayed URL.
|
|
14
|
-
*/
|
|
15
|
-
export function filterURLForDisplay(url, maxLength = null) {
|
|
1
|
+
function filterURLForDisplay(url, maxLength = null) {
|
|
16
2
|
if (!url) {
|
|
17
|
-
return
|
|
3
|
+
return "";
|
|
18
4
|
}
|
|
19
|
-
|
|
20
|
-
// Remove protocol and www prefixes.
|
|
21
|
-
let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, '').replace(/^www\./i, '');
|
|
22
|
-
|
|
23
|
-
// Ends with / and only has that single slash, strip it.
|
|
5
|
+
let filteredURL = url.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, "").replace(/^www\./i, "");
|
|
24
6
|
if (filteredURL.match(/^[^\/]+\/$/)) {
|
|
25
|
-
filteredURL = filteredURL.replace(
|
|
7
|
+
filteredURL = filteredURL.replace("/", "");
|
|
26
8
|
}
|
|
27
|
-
|
|
28
|
-
// capture file name from URL
|
|
29
9
|
const fileRegexp = /\/([^\/?]+)\.(?:[\w]+)(?=\?|$)/;
|
|
30
10
|
if (!maxLength || filteredURL.length <= maxLength || !filteredURL.match(fileRegexp)) {
|
|
31
11
|
return filteredURL;
|
|
32
12
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
filteredURL = filteredURL.split('?')[0];
|
|
36
|
-
const urlPieces = filteredURL.split('/');
|
|
13
|
+
filteredURL = filteredURL.split("?")[0];
|
|
14
|
+
const urlPieces = filteredURL.split("/");
|
|
37
15
|
const file = urlPieces[urlPieces.length - 1];
|
|
38
16
|
if (file.length <= maxLength) {
|
|
39
|
-
return
|
|
17
|
+
return "\u2026" + filteredURL.slice(-maxLength);
|
|
40
18
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
19
|
+
const index = file.lastIndexOf(".");
|
|
20
|
+
const [fileName, extension] = [
|
|
21
|
+
file.slice(0, index),
|
|
22
|
+
file.slice(index + 1)
|
|
23
|
+
];
|
|
24
|
+
const truncatedFile = fileName.slice(-3) + "." + extension;
|
|
25
|
+
return file.slice(0, maxLength - truncatedFile.length - 1) + "\u2026" + truncatedFile;
|
|
47
26
|
}
|
|
48
|
-
|
|
27
|
+
export {
|
|
28
|
+
filterURLForDisplay
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=filter-url-for-display.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/filter-url-for-display.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns a URL for display.\n *\n * @param url Original URL.\n * @param maxLength URL length.\n *\n * @example\n * ```js\n * const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg\n * const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // \u2026ent/uploads/img.png\n * ```\n *\n * @return Displayed URL.\n */\nexport function filterURLForDisplay(\n\turl: string,\n\tmaxLength: number | null = null\n): string {\n\tif ( ! url ) {\n\t\treturn '';\n\t}\n\n\t// Remove protocol and www prefixes.\n\tlet filteredURL = url\n\t\t.replace( /^[a-z\\-.\\+]+[0-9]*:(\\/\\/)?/i, '' )\n\t\t.replace( /^www\\./i, '' );\n\n\t// Ends with / and only has that single slash, strip it.\n\tif ( filteredURL.match( /^[^\\/]+\\/$/ ) ) {\n\t\tfilteredURL = filteredURL.replace( '/', '' );\n\t}\n\n\t// capture file name from URL\n\tconst fileRegexp = /\\/([^\\/?]+)\\.(?:[\\w]+)(?=\\?|$)/;\n\n\tif (\n\t\t! maxLength ||\n\t\tfilteredURL.length <= maxLength ||\n\t\t! filteredURL.match( fileRegexp )\n\t) {\n\t\treturn filteredURL;\n\t}\n\n\t// If the file is not greater than max length, return last portion of URL.\n\tfilteredURL = filteredURL.split( '?' )[ 0 ];\n\tconst urlPieces = filteredURL.split( '/' );\n\tconst file = urlPieces[ urlPieces.length - 1 ];\n\tif ( file.length <= maxLength ) {\n\t\treturn '\u2026' + filteredURL.slice( -maxLength );\n\t}\n\n\t// If the file is greater than max length, truncate the file.\n\tconst index = file.lastIndexOf( '.' );\n\tconst [ fileName, extension ] = [\n\t\tfile.slice( 0, index ),\n\t\tfile.slice( index + 1 ),\n\t];\n\tconst truncatedFile = fileName.slice( -3 ) + '.' + extension;\n\treturn (\n\t\tfile.slice( 0, maxLength - truncatedFile.length - 1 ) +\n\t\t'\u2026' +\n\t\ttruncatedFile\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAcO,SAAS,oBACf,KACA,YAA2B,MAClB;AACT,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,MAAI,cAAc,IAChB,QAAS,+BAA+B,EAAG,EAC3C,QAAS,WAAW,EAAG;AAGzB,MAAK,YAAY,MAAO,YAAa,GAAI;AACxC,kBAAc,YAAY,QAAS,KAAK,EAAG;AAAA,EAC5C;AAGA,QAAM,aAAa;AAEnB,MACC,CAAE,aACF,YAAY,UAAU,aACtB,CAAE,YAAY,MAAO,UAAW,GAC/B;AACD,WAAO;AAAA,EACR;AAGA,gBAAc,YAAY,MAAO,GAAI,EAAG,CAAE;AAC1C,QAAM,YAAY,YAAY,MAAO,GAAI;AACzC,QAAM,OAAO,UAAW,UAAU,SAAS,CAAE;AAC7C,MAAK,KAAK,UAAU,WAAY;AAC/B,WAAO,WAAM,YAAY,MAAO,CAAC,SAAU;AAAA,EAC5C;AAGA,QAAM,QAAQ,KAAK,YAAa,GAAI;AACpC,QAAM,CAAE,UAAU,SAAU,IAAI;AAAA,IAC/B,KAAK,MAAO,GAAG,KAAM;AAAA,IACrB,KAAK,MAAO,QAAQ,CAAE;AAAA,EACvB;AACA,QAAM,gBAAgB,SAAS,MAAO,EAAG,IAAI,MAAM;AACnD,SACC,KAAK,MAAO,GAAG,YAAY,cAAc,SAAS,CAAE,IACpD,WACA;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'
|
|
9
|
-
* const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return The authority part of the URL.
|
|
13
|
-
*/
|
|
14
|
-
export function getAuthority(url) {
|
|
15
|
-
const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(url);
|
|
1
|
+
function getAuthority(url) {
|
|
2
|
+
const matches = /^[^\/\s:]+:(?:\/\/)?\/?([^\/\s#?]+)[\/#?]{0,1}\S*$/.exec(
|
|
3
|
+
url
|
|
4
|
+
);
|
|
16
5
|
if (matches) {
|
|
17
6
|
return matches[1];
|
|
18
7
|
}
|
|
19
8
|
}
|
|
20
|
-
|
|
9
|
+
export {
|
|
10
|
+
getAuthority
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=get-authority.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-authority.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the authority part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const authority1 = getAuthority( 'https://wordpress.org/help/' ); // 'wordpress.org'\n * const authority2 = getAuthority( 'https://localhost:8080/test/' ); // 'localhost:8080'\n * ```\n *\n * @return The authority part of the URL.\n */\nexport function getAuthority( url: string ): string | void {\n\tconst matches = /^[^\\/\\s:]+:(?:\\/\\/)?\\/?([^\\/\\s#?]+)[\\/#?]{0,1}\\S*$/.exec(\n\t\turl\n\t);\n\tif ( matches ) {\n\t\treturn matches[ 1 ];\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,aAAc,KAA6B;AAC1D,QAAM,UAAU,qDAAqD;AAAA,IACpE;AAAA,EACD;AACA,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Returns the filename part of the URL.
|
|
4
|
-
*
|
|
5
|
-
* @param url The full URL.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'
|
|
10
|
-
* const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @return The filename part of the URL.
|
|
14
|
-
*/
|
|
15
|
-
export function getFilename(url) {
|
|
1
|
+
function getFilename(url) {
|
|
16
2
|
let filename;
|
|
17
3
|
if (!url) {
|
|
18
4
|
return;
|
|
19
5
|
}
|
|
20
6
|
try {
|
|
21
|
-
filename = new URL(url,
|
|
22
|
-
} catch (error) {
|
|
7
|
+
filename = new URL(url, "http://example.com").pathname.split("/").pop();
|
|
8
|
+
} catch (error) {
|
|
9
|
+
}
|
|
23
10
|
if (filename) {
|
|
24
11
|
return filename;
|
|
25
12
|
}
|
|
26
13
|
}
|
|
27
|
-
|
|
14
|
+
export {
|
|
15
|
+
getFilename
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=get-filename.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/get-filename.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Returns the filename part of the URL.\n *\n * @param url The full URL.\n *\n * @example\n * ```js\n * const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'\n * const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'\n * ```\n *\n * @return The filename part of the URL.\n */\nexport function getFilename( url: string ): string | void {\n\tlet filename;\n\n\tif ( ! url ) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tfilename = new URL( url, 'http://example.com' ).pathname\n\t\t\t.split( '/' )\n\t\t\t.pop();\n\t} catch ( error ) {}\n\n\tif ( filename ) {\n\t\treturn filename;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAaO,SAAS,YAAa,KAA6B;AACzD,MAAI;AAEJ,MAAK,CAAE,KAAM;AACZ;AAAA,EACD;AAEA,MAAI;AACH,eAAW,IAAI,IAAK,KAAK,oBAAqB,EAAE,SAC9C,MAAO,GAAI,EACX,IAAI;AAAA,EACP,SAAU,OAAQ;AAAA,EAAC;AAEnB,MAAK,UAAW;AACf,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Returns the fragment part of the URL.
|
|
3
|
-
*
|
|
4
|
-
* @param url The full URL
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```js
|
|
8
|
-
* const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
|
|
9
|
-
* const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* @return The fragment part of the URL.
|
|
13
|
-
*/
|
|
14
|
-
export function getFragment(url) {
|
|
1
|
+
function getFragment(url) {
|
|
15
2
|
const matches = /^\S+?(#[^\s\?]*)/.exec(url);
|
|
16
3
|
if (matches) {
|
|
17
4
|
return matches[1];
|
|
18
5
|
}
|
|
19
6
|
}
|
|
20
|
-
|
|
7
|
+
export {
|
|
8
|
+
getFragment
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=get-fragment.js.map
|
|
@@ -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": "AAaO,SAAS,YAAa,KAA6B;AACzD,QAAM,UAAU,mBAAmB,KAAM,GAAI;AAC7C,MAAK,SAAU;AACd,WAAO,QAAS,CAAE;AAAA,EACnB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { getPath, getQueryString } from '.';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Returns the path part and query string part of the URL.
|
|
8
|
-
*
|
|
9
|
-
* @param url The full URL.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```js
|
|
13
|
-
* const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
|
|
14
|
-
* const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @return The path part and query string part of the URL.
|
|
18
|
-
*/
|
|
19
|
-
export function getPathAndQueryString(url) {
|
|
1
|
+
import { getPath, getQueryString } from ".";
|
|
2
|
+
function getPathAndQueryString(url) {
|
|
20
3
|
const path = getPath(url);
|
|
21
4
|
const queryString = getQueryString(url);
|
|
22
|
-
let value =
|
|
5
|
+
let value = "/";
|
|
23
6
|
if (path) {
|
|
24
7
|
value += path;
|
|
25
8
|
}
|
|
@@ -28,4 +11,7 @@ export function getPathAndQueryString(url) {
|
|
|
28
11
|
}
|
|
29
12
|
return value;
|
|
30
13
|
}
|
|
31
|
-
|
|
14
|
+
export {
|
|
15
|
+
getPathAndQueryString
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=get-path-and-query-string.js.map
|