@wordpress/url 2.21.3-next.645224df70.0 → 2.21.3
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/README.md +7 -7
- package/build/get-query-arg.js +4 -0
- package/build/get-query-arg.js.map +1 -1
- package/build/get-query-args.js +4 -3
- package/build/get-query-args.js.map +1 -1
- package/build-module/get-query-arg.js +4 -0
- package/build-module/get-query-arg.js.map +1 -1
- package/build-module/get-query-args.js +4 -3
- package/build-module/get-query-args.js.map +1 -1
- package/build-types/get-filename.d.ts +15 -0
- package/build-types/get-filename.d.ts.map +1 -0
- package/build-types/get-query-arg.d.ts.map +1 -1
- package/build-types/get-query-args.d.ts.map +1 -1
- package/build-types/normalize-path.d.ts +11 -0
- package/build-types/normalize-path.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/get-query-arg.js +2 -0
- package/src/get-query-args.js +5 -1
- package/tsconfig.tsbuildinfo +2 -2
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uplo
|
|
|
102
102
|
_Parameters_
|
|
103
103
|
|
|
104
104
|
- _url_ `string`: Original URL.
|
|
105
|
-
- _maxLength_ `number|null`: URL length.
|
|
105
|
+
- _maxLength_ `(number|null)`: URL length.
|
|
106
106
|
|
|
107
107
|
_Returns_
|
|
108
108
|
|
|
@@ -125,7 +125,7 @@ _Parameters_
|
|
|
125
125
|
|
|
126
126
|
_Returns_
|
|
127
127
|
|
|
128
|
-
- `string|void`: The authority part of the URL.
|
|
128
|
+
- `(string|void)`: The authority part of the URL.
|
|
129
129
|
|
|
130
130
|
<a name="getFragment" href="#getFragment">#</a> **getFragment**
|
|
131
131
|
|
|
@@ -144,7 +144,7 @@ _Parameters_
|
|
|
144
144
|
|
|
145
145
|
_Returns_
|
|
146
146
|
|
|
147
|
-
- `string|void`: The fragment part of the URL.
|
|
147
|
+
- `(string|void)`: The fragment part of the URL.
|
|
148
148
|
|
|
149
149
|
<a name="getPath" href="#getPath">#</a> **getPath**
|
|
150
150
|
|
|
@@ -163,7 +163,7 @@ _Parameters_
|
|
|
163
163
|
|
|
164
164
|
_Returns_
|
|
165
165
|
|
|
166
|
-
- `string|void`: The path part of the URL.
|
|
166
|
+
- `(string|void)`: The path part of the URL.
|
|
167
167
|
|
|
168
168
|
<a name="getPathAndQueryString" href="#getPathAndQueryString">#</a> **getPathAndQueryString**
|
|
169
169
|
|
|
@@ -201,7 +201,7 @@ _Parameters_
|
|
|
201
201
|
|
|
202
202
|
_Returns_
|
|
203
203
|
|
|
204
|
-
- `string|void`: The protocol part of the URL.
|
|
204
|
+
- `(string|void)`: The protocol part of the URL.
|
|
205
205
|
|
|
206
206
|
<a name="getQueryArg" href="#getQueryArg">#</a> **getQueryArg**
|
|
207
207
|
|
|
@@ -220,7 +220,7 @@ _Parameters_
|
|
|
220
220
|
|
|
221
221
|
_Returns_
|
|
222
222
|
|
|
223
|
-
- `QueryArgParsed|void`: Query arg value.
|
|
223
|
+
- `(QueryArgParsed|void)`: Query arg value.
|
|
224
224
|
|
|
225
225
|
<a name="getQueryArgs" href="#getQueryArgs">#</a> **getQueryArgs**
|
|
226
226
|
|
|
@@ -258,7 +258,7 @@ _Parameters_
|
|
|
258
258
|
|
|
259
259
|
_Returns_
|
|
260
260
|
|
|
261
|
-
- `string|void`: The query string part of the URL.
|
|
261
|
+
- `(string|void)`: The query string part of the URL.
|
|
262
262
|
|
|
263
263
|
<a name="hasQueryArg" href="#hasQueryArg">#</a> **hasQueryArg**
|
|
264
264
|
|
package/build/get-query-arg.js
CHANGED
|
@@ -11,10 +11,14 @@ var _getQueryArgs = require("./get-query-args");
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/* eslint-disable jsdoc/valid-types */
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
|
|
16
18
|
*/
|
|
17
19
|
|
|
20
|
+
/* eslint-enable */
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
|
|
20
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/url/src/get-query-arg.js"],"names":["getQueryArg","url","arg"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,GAAtB,EAA2BC,GAA3B,EAAiC;AACvC,SAAO,gCAAcD,GAAd,EAAqBC,GAArB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\n/**\n * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject\n */\n\n/**\n * @typedef {string|string[]|QueryArgObject} QueryArgParsed\n */\n\n/**\n * Returns a single query argument of the url\n *\n * @param {string} url URL.\n * @param {string} 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 {QueryArgParsed|void} Query arg value.\n */\nexport function getQueryArg( url, arg ) {\n\treturn getQueryArgs( url )[ arg ];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/url/src/get-query-arg.js"],"names":["getQueryArg","url","arg"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,GAAtB,EAA2BC,GAA3B,EAAiC;AACvC,SAAO,gCAAcD,GAAd,EAAqBC,GAArB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject\n */\n/* eslint-enable */\n\n/**\n * @typedef {string|string[]|QueryArgObject} QueryArgParsed\n */\n\n/**\n * Returns a single query argument of the url\n *\n * @param {string} url URL.\n * @param {string} 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 {QueryArgParsed|void} Query arg value.\n */\nexport function getQueryArg( url, arg ) {\n\treturn getQueryArgs( url )[ arg ];\n}\n"]}
|
package/build/get-query-args.js
CHANGED
|
@@ -42,9 +42,10 @@ function setPath(object, path, value) {
|
|
|
42
42
|
// If key is empty string and next value is array, derive key from
|
|
43
43
|
// the current length of the array.
|
|
44
44
|
key = object.length.toString();
|
|
45
|
-
}
|
|
46
|
-
// created as an array. Otherwise, it will be created as an object.
|
|
45
|
+
}
|
|
47
46
|
|
|
47
|
+
key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be
|
|
48
|
+
// created as an array. Otherwise, it will be created as an object.
|
|
48
49
|
|
|
49
50
|
var isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
|
|
50
51
|
object[key] = i === lastIndex ? // If at end of path, assign the intended value.
|
|
@@ -98,6 +99,6 @@ function getQueryArgs(url) {
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
return accumulator;
|
|
101
|
-
},
|
|
102
|
+
}, Object.create(null));
|
|
102
103
|
}
|
|
103
104
|
//# sourceMappingURL=get-query-args.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/url/src/get-query-args.js"],"names":["setPath","object","path","value","length","lastIndex","i","key","Array","isArray","toString","isNextKeyArrayIndex","isNaN","Number","getQueryArgs","url","replace","split","reduce","accumulator","keyValue","filter","Boolean","map","decodeURIComponent","segments"],"mappings":";;;;;;;;;;;;;AAGA;;;;;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,MAAlB,EAA0BC,IAA1B,EAAgCC,KAAhC,EAAwC;AACvC,MAAMC,MAAM,GAAGF,IAAI,CAACE,MAApB;AACA,MAAMC,SAAS,GAAGD,MAAM,GAAG,CAA3B;;AACA,OAAM,IAAIE,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGF,MAArB,EAA6BE,CAAC,EAA9B,EAAmC;AAClC,QAAIC,GAAG,GAAGL,IAAI,CAAEI,CAAF,CAAd;;AAEA,QAAK,CAAEC,GAAF,IAASC,KAAK,CAACC,OAAN,CAAeR,MAAf,CAAd,EAAwC;AACvC;AACA;AACAM,MAAAA,GAAG,GAAGN,MAAM,CAACG,MAAP,CAAcM,QAAd,EAAN;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/url/src/get-query-args.js"],"names":["setPath","object","path","value","length","lastIndex","i","key","Array","isArray","toString","includes","toUpperCase","isNextKeyArrayIndex","isNaN","Number","getQueryArgs","url","replace","split","reduce","accumulator","keyValue","filter","Boolean","map","decodeURIComponent","segments","Object","create"],"mappings":";;;;;;;;;;;;;AAGA;;;;;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,MAAlB,EAA0BC,IAA1B,EAAgCC,KAAhC,EAAwC;AACvC,MAAMC,MAAM,GAAGF,IAAI,CAACE,MAApB;AACA,MAAMC,SAAS,GAAGD,MAAM,GAAG,CAA3B;;AACA,OAAM,IAAIE,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGF,MAArB,EAA6BE,CAAC,EAA9B,EAAmC;AAClC,QAAIC,GAAG,GAAGL,IAAI,CAAEI,CAAF,CAAd;;AAEA,QAAK,CAAEC,GAAF,IAASC,KAAK,CAACC,OAAN,CAAeR,MAAf,CAAd,EAAwC;AACvC;AACA;AACAM,MAAAA,GAAG,GAA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AAA;AAAA,QACxBJ,KADwB,uCAChB,EADgB;;AAQrC,QAAKI,GAAL,EAAW;AACV,UAAMoB,QAAQ,GAAGpB,GAAG,CAACW,OAAJ,CAAa,KAAb,EAAoB,EAApB,EAAyBC,KAAzB,CAAgC,GAAhC,CAAjB;AACAnB,MAAAA,OAAO,CAAEqB,WAAF,EAAeM,QAAf,EAAyBxB,KAAzB,CAAP;AACA;;AAED,WAAOkB,WAAP;AACA,GArBF,EAqBIO,MAAM,CAACC,MAAP,CAAe,IAAf,CArBJ,CADD;AAwBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryString } from './get-query-string';\n\n/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */\n\n/**\n * @typedef {Record<string,QueryArgParsed>} QueryArgs\n */\n\n/**\n * Sets a value in object deeply by a given array of path segments. Mutates the\n * object reference.\n *\n * @param {Record<string,*>} object Object in which to assign.\n * @param {string[]} path Path segment at which to set value.\n * @param {*} value Value to set.\n */\nfunction setPath( object, path, value ) {\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 {string} 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 {QueryArgs} Query args object.\n */\nexport function getQueryArgs( url ) {\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( decodeURIComponent );\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"]}
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getQueryArgs } from './get-query-args';
|
|
5
|
+
/* eslint-disable jsdoc/valid-types */
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
|
|
7
9
|
*/
|
|
8
10
|
|
|
11
|
+
/* eslint-enable */
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
14
|
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
|
|
11
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/url/src/get-query-arg.js"],"names":["getQueryArgs","getQueryArg","url","arg"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,GAAtB,EAA2BC,GAA3B,EAAiC;AACvC,SAAOH,YAAY,CAAEE,GAAF,CAAZ,CAAqBC,GAArB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\n/**\n * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject\n */\n\n/**\n * @typedef {string|string[]|QueryArgObject} QueryArgParsed\n */\n\n/**\n * Returns a single query argument of the url\n *\n * @param {string} url URL.\n * @param {string} 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 {QueryArgParsed|void} Query arg value.\n */\nexport function getQueryArg( url, arg ) {\n\treturn getQueryArgs( url )[ arg ];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/url/src/get-query-arg.js"],"names":["getQueryArgs","getQueryArg","url","arg"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,kBAA7B;AAEA;;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,GAAtB,EAA2BC,GAA3B,EAAiC;AACvC,SAAOH,YAAY,CAAEE,GAAF,CAAZ,CAAqBC,GAArB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryArgs } from './get-query-args';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef {{[key: string]: QueryArgParsed}} QueryArgObject\n */\n/* eslint-enable */\n\n/**\n * @typedef {string|string[]|QueryArgObject} QueryArgParsed\n */\n\n/**\n * Returns a single query argument of the url\n *\n * @param {string} url URL.\n * @param {string} 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 {QueryArgParsed|void} Query arg value.\n */\nexport function getQueryArg( url, arg ) {\n\treturn getQueryArgs( url )[ arg ];\n}\n"]}
|
|
@@ -35,9 +35,10 @@ function setPath(object, path, value) {
|
|
|
35
35
|
// If key is empty string and next value is array, derive key from
|
|
36
36
|
// the current length of the array.
|
|
37
37
|
key = object.length.toString();
|
|
38
|
-
}
|
|
39
|
-
// created as an array. Otherwise, it will be created as an object.
|
|
38
|
+
}
|
|
40
39
|
|
|
40
|
+
key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be
|
|
41
|
+
// created as an array. Otherwise, it will be created as an object.
|
|
41
42
|
|
|
42
43
|
var isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
|
|
43
44
|
object[key] = i === lastIndex ? // If at end of path, assign the intended value.
|
|
@@ -91,6 +92,6 @@ export function getQueryArgs(url) {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
return accumulator;
|
|
94
|
-
},
|
|
95
|
+
}, Object.create(null));
|
|
95
96
|
}
|
|
96
97
|
//# sourceMappingURL=get-query-args.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/url/src/get-query-args.js"],"names":["getQueryString","setPath","object","path","value","length","lastIndex","i","key","Array","isArray","toString","isNextKeyArrayIndex","isNaN","Number","getQueryArgs","url","replace","split","reduce","accumulator","keyValue","filter","Boolean","map","decodeURIComponent","segments"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,oBAA/B;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,CAAkBC,MAAlB,EAA0BC,IAA1B,EAAgCC,KAAhC,EAAwC;AACvC,MAAMC,MAAM,GAAGF,IAAI,CAACE,MAApB;AACA,MAAMC,SAAS,GAAGD,MAAM,GAAG,CAA3B;;AACA,OAAM,IAAIE,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGF,MAArB,EAA6BE,CAAC,EAA9B,EAAmC;AAClC,QAAIC,GAAG,GAAGL,IAAI,CAAEI,CAAF,CAAd;;AAEA,QAAK,CAAEC,GAAF,IAASC,KAAK,CAACC,OAAN,CAAeR,MAAf,CAAd,EAAwC;AACvC;AACA;AACAM,MAAAA,GAAG,GAAGN,MAAM,CAACG,MAAP,CAAcM,QAAd,EAAN;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/url/src/get-query-args.js"],"names":["getQueryString","setPath","object","path","value","length","lastIndex","i","key","Array","isArray","toString","includes","toUpperCase","isNextKeyArrayIndex","isNaN","Number","getQueryArgs","url","replace","split","reduce","accumulator","keyValue","filter","Boolean","map","decodeURIComponent","segments","Object","create"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,oBAA/B;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,CAAkBC,MAAlB,EAA0BC,IAA1B,EAAgCC,KAAhC,EAAwC;AACvC,MAAMC,MAAM,GAAGF,IAAI,CAACE,MAApB;AACA,MAAMC,SAAS,GAAGD,MAAM,GAAG,CAA3B;;AACA,OAAM,IAAIE,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGF,MAArB,EAA6BE,CAAC,EAA9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AF,EAAeC,QAAf,EAA6B;AAAA,gCACTA,QAAQ,CAClCH,KAD0B,CACnB,GADmB,EAE3B;AACA;AAH2B,KAI1BI,MAJ0B,CAIlBC,OAJkB,EAK1BC,GAL0B,CAKrBC,kBALqB,CADS;AAAA;AAAA,QAC7BnB,GAD6B;AAAA;AAAA,QACxBJ,KADwB,uCAChB,EADgB;;AAQrC,QAAKI,GAAL,EAAW;AACV,UAAMoB,QAAQ,GAAGpB,GAAG,CAACW,OAAJ,CAAa,KAAb,EAAoB,EAApB,EAAyBC,KAAzB,CAAgC,GAAhC,CAAjB;AACAnB,MAAAA,OAAO,CAAEqB,WAAF,EAAeM,QAAf,EAAyBxB,KAAzB,CAAP;AACA;;AAED,WAAOkB,WAAP;AACA,GArBF,EAqBIO,MAAM,CAACC,MAAP,CAAe,IAAf,CArBJ,CADD;AAwBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getQueryString } from './get-query-string';\n\n/** @typedef {import('./get-query-arg').QueryArgParsed} QueryArgParsed */\n\n/**\n * @typedef {Record<string,QueryArgParsed>} QueryArgs\n */\n\n/**\n * Sets a value in object deeply by a given array of path segments. Mutates the\n * object reference.\n *\n * @param {Record<string,*>} object Object in which to assign.\n * @param {string[]} path Path segment at which to set value.\n * @param {*} value Value to set.\n */\nfunction setPath( object, path, value ) {\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 {string} 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 {QueryArgs} Query args object.\n */\nexport function getQueryArgs( url ) {\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( decodeURIComponent );\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"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the filename part of the URL.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} url The full URL.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```js
|
|
8
|
+
* const filename1 = getFilename( 'http://localhost:8080/this/is/a/test.jpg' ); // 'test.jpg'
|
|
9
|
+
* const filename2 = getFilename( '/this/is/a/test.png' ); // 'test.png'
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @return {string|void} The filename part of the URL.
|
|
13
|
+
*/
|
|
14
|
+
export function getFilename(url: string): string | void;
|
|
15
|
+
//# sourceMappingURL=get-filename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-filename.d.ts","sourceRoot":"","sources":["../src/get-filename.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,iCAVW,MAAM,GAQL,MAAM,GAAC,IAAI,CAatB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-query-arg.d.ts","sourceRoot":"","sources":["../src/get-query-arg.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-query-arg.d.ts","sourceRoot":"","sources":["../src/get-query-arg.js"],"names":[],"mappings":"AAMA;;GAEG;AAGH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,iCAVW,MAAM,OACN,MAAM,GAOL,cAAc,GAAC,IAAI,CAI9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-query-args.d.ts","sourceRoot":"","sources":["../src/get-query-args.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-query-args.d.ts","sourceRoot":"","sources":["../src/get-query-args.js"],"names":[],"mappings":"AA0DA;;;;;;;;;;;;;GAaG;AACH,kCAVW,MAAM,GAQL,SAAS,CA2BpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a path, returns a normalized path where equal query parameter values
|
|
3
|
+
* will be treated as identical, regardless of order they appear in the original
|
|
4
|
+
* text.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} path Original path.
|
|
7
|
+
*
|
|
8
|
+
* @return {string} Normalized path.
|
|
9
|
+
*/
|
|
10
|
+
export function normalizePath(path: string): string;
|
|
11
|
+
//# sourceMappingURL=normalize-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-path.d.ts","sourceRoot":"","sources":["../src/normalize-path.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,oCAJW,MAAM,GAEL,MAAM,CA0BjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/url",
|
|
3
|
-
"version": "2.21.3
|
|
3
|
+
"version": "2.21.3",
|
|
4
4
|
"description": "WordPress URL utilities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "14a64efc7cf32f4d37400902a7c1cbb822bc5c2f"
|
|
35
35
|
}
|
package/src/get-query-arg.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { getQueryArgs } from './get-query-args';
|
|
5
5
|
|
|
6
|
+
/* eslint-disable jsdoc/valid-types */
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {{[key: string]: QueryArgParsed}} QueryArgObject
|
|
8
9
|
*/
|
|
10
|
+
/* eslint-enable */
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* @typedef {string|string[]|QueryArgObject} QueryArgParsed
|
package/src/get-query-args.js
CHANGED
|
@@ -29,6 +29,10 @@ function setPath( object, path, value ) {
|
|
|
29
29
|
key = object.length.toString();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
key = [ '__proto__', 'constructor', 'prototype' ].includes( key )
|
|
33
|
+
? key.toUpperCase()
|
|
34
|
+
: key;
|
|
35
|
+
|
|
32
36
|
// If the next key in the path is numeric (or empty string), it will be
|
|
33
37
|
// created as an array. Otherwise, it will be created as an object.
|
|
34
38
|
const isNextKeyArrayIndex = ! isNaN( Number( path[ i + 1 ] ) );
|
|
@@ -89,6 +93,6 @@ export function getQueryArgs( url ) {
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
return accumulator;
|
|
92
|
-
},
|
|
96
|
+
}, Object.create( null ) )
|
|
93
97
|
);
|
|
94
98
|
}
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -222,12 +222,12 @@
|
|
|
222
222
|
"affectsGlobalScope": false
|
|
223
223
|
},
|
|
224
224
|
"./src/get-query-arg.js": {
|
|
225
|
-
"version": "
|
|
225
|
+
"version": "897178a4696adb66ad8ed8b0e14870dbb30a5380189ee67e0766e77c11cb76d4",
|
|
226
226
|
"signature": "a2bedf5636ce572e507823229c9b7d4e87d97830497822d76e95a971fee78c92",
|
|
227
227
|
"affectsGlobalScope": false
|
|
228
228
|
},
|
|
229
229
|
"./src/get-query-args.js": {
|
|
230
|
-
"version": "
|
|
230
|
+
"version": "7bb4d57a1385212fb584dbf91a55fd4b82a88dedd8a73d40a4d6199155f404d5",
|
|
231
231
|
"signature": "d24b1424b4a4a0f2cc08685bdead834018bf5bdd4de1fd8b3c44648b8fd4e2f3",
|
|
232
232
|
"affectsGlobalScope": false
|
|
233
233
|
},
|