@wordpress/url 3.1.0 → 3.1.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 CHANGED
@@ -16,7 +16,7 @@ _This package assumes that your code will run in an **ES2015+** environment. If
16
16
 
17
17
  <!-- START TOKEN(Autogenerated API docs) -->
18
18
 
19
- <a name="addQueryArgs" href="#addQueryArgs">#</a> **addQueryArgs**
19
+ ### addQueryArgs
20
20
 
21
21
  Appends arguments as querystring to the provided URL. If the URL already
22
22
  includes query arguments, the arguments are merged with (and take precedent
@@ -37,7 +37,7 @@ _Returns_
37
37
 
38
38
  - `string`: URL with arguments applied.
39
39
 
40
- <a name="buildQueryString" href="#buildQueryString">#</a> **buildQueryString**
40
+ ### buildQueryString
41
41
 
42
42
  Generates URL-encoded query string using input query data.
43
43
 
@@ -48,13 +48,13 @@ _Usage_
48
48
 
49
49
  ```js
50
50
  const queryString = buildQueryString( {
51
- simple: 'is ok',
52
- arrays: [ 'are', 'fine', 'too' ],
53
- objects: {
54
- evenNested: {
55
- ok: 'yes',
56
- },
57
- },
51
+ simple: 'is ok',
52
+ arrays: [ 'are', 'fine', 'too' ],
53
+ objects: {
54
+ evenNested: {
55
+ ok: 'yes',
56
+ },
57
+ },
58
58
  } );
59
59
  // "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"
60
60
  ```
@@ -67,7 +67,7 @@ _Returns_
67
67
 
68
68
  - `string`: Query string.
69
69
 
70
- <a name="cleanForSlug" href="#cleanForSlug">#</a> **cleanForSlug**
70
+ ### cleanForSlug
71
71
 
72
72
  Performs some basic cleanup of a string for use as a post slug.
73
73
 
@@ -88,15 +88,20 @@ _Returns_
88
88
 
89
89
  - `string`: Processed string.
90
90
 
91
- <a name="filterURLForDisplay" href="#filterURLForDisplay">#</a> **filterURLForDisplay**
91
+ ### filterURLForDisplay
92
92
 
93
93
  Returns a URL for display.
94
94
 
95
95
  _Usage_
96
96
 
97
97
  ```js
98
- const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg
99
- const imageUrl = filterURLForDisplay( 'https://www.wordpress.org/wp-content/uploads/img.png', 20 ); // …ent/uploads/img.png
98
+ const displayUrl = filterURLForDisplay(
99
+ 'https://www.wordpress.org/gutenberg/'
100
+ ); // wordpress.org/gutenberg
101
+ const imageUrl = filterURLForDisplay(
102
+ 'https://www.wordpress.org/wp-content/uploads/img.png',
103
+ 20
104
+ ); // …ent/uploads/img.png
100
105
  ```
101
106
 
102
107
  _Parameters_
@@ -108,7 +113,7 @@ _Returns_
108
113
 
109
114
  - `string`: Displayed URL.
110
115
 
111
- <a name="getAuthority" href="#getAuthority">#</a> **getAuthority**
116
+ ### getAuthority
112
117
 
113
118
  Returns the authority part of the URL.
114
119
 
@@ -127,15 +132,19 @@ _Returns_
127
132
 
128
133
  - `string|void`: The authority part of the URL.
129
134
 
130
- <a name="getFragment" href="#getFragment">#</a> **getFragment**
135
+ ### getFragment
131
136
 
132
137
  Returns the fragment part of the URL.
133
138
 
134
139
  _Usage_
135
140
 
136
141
  ```js
137
- const fragment1 = getFragment( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // '#fragment'
138
- const fragment2 = getFragment( 'https://wordpress.org#another-fragment?query=true' ); // '#another-fragment'
142
+ const fragment1 = getFragment(
143
+ 'http://localhost:8080/this/is/a/test?query=true#fragment'
144
+ ); // '#fragment'
145
+ const fragment2 = getFragment(
146
+ 'https://wordpress.org#another-fragment?query=true'
147
+ ); // '#another-fragment'
139
148
  ```
140
149
 
141
150
  _Parameters_
@@ -146,7 +155,7 @@ _Returns_
146
155
 
147
156
  - `string|void`: The fragment part of the URL.
148
157
 
149
- <a name="getPath" href="#getPath">#</a> **getPath**
158
+ ### getPath
150
159
 
151
160
  Returns the path part of the URL.
152
161
 
@@ -165,15 +174,19 @@ _Returns_
165
174
 
166
175
  - `string|void`: The path part of the URL.
167
176
 
168
- <a name="getPathAndQueryString" href="#getPathAndQueryString">#</a> **getPathAndQueryString**
177
+ ### getPathAndQueryString
169
178
 
170
179
  Returns the path part and query string part of the URL.
171
180
 
172
181
  _Usage_
173
182
 
174
183
  ```js
175
- const pathAndQueryString1 = getPathAndQueryString( 'http://localhost:8080/this/is/a/test?query=true' ); // '/this/is/a/test?query=true'
176
- const pathAndQueryString2 = getPathAndQueryString( 'https://wordpress.org/help/faq/' ); // '/help/faq'
184
+ const pathAndQueryString1 = getPathAndQueryString(
185
+ 'http://localhost:8080/this/is/a/test?query=true'
186
+ ); // '/this/is/a/test?query=true'
187
+ const pathAndQueryString2 = getPathAndQueryString(
188
+ 'https://wordpress.org/help/faq/'
189
+ ); // '/help/faq'
177
190
  ```
178
191
 
179
192
  _Parameters_
@@ -184,7 +197,7 @@ _Returns_
184
197
 
185
198
  - `string`: The path part and query string part of the URL.
186
199
 
187
- <a name="getProtocol" href="#getProtocol">#</a> **getProtocol**
200
+ ### getProtocol
188
201
 
189
202
  Returns the protocol part of the URL.
190
203
 
@@ -203,7 +216,7 @@ _Returns_
203
216
 
204
217
  - `string|void`: The protocol part of the URL.
205
218
 
206
- <a name="getQueryArg" href="#getQueryArg">#</a> **getQueryArg**
219
+ ### getQueryArg
207
220
 
208
221
  Returns a single query argument of the url
209
222
 
@@ -222,7 +235,7 @@ _Returns_
222
235
 
223
236
  - `QueryArgParsed|void`: Query arg value.
224
237
 
225
- <a name="getQueryArgs" href="#getQueryArgs">#</a> **getQueryArgs**
238
+ ### getQueryArgs
226
239
 
227
240
  Returns an object of query arguments of the given URL. If the given URL is
228
241
  invalid or has no querystring, an empty object is returned.
@@ -242,14 +255,16 @@ _Returns_
242
255
 
243
256
  - `QueryArgs`: Query args object.
244
257
 
245
- <a name="getQueryString" href="#getQueryString">#</a> **getQueryString**
258
+ ### getQueryString
246
259
 
247
260
  Returns the query string part of the URL.
248
261
 
249
262
  _Usage_
250
263
 
251
264
  ```js
252
- const queryString = getQueryString( 'http://localhost:8080/this/is/a/test?query=true#fragment' ); // 'query=true'
265
+ const queryString = getQueryString(
266
+ 'http://localhost:8080/this/is/a/test?query=true#fragment'
267
+ ); // 'query=true'
253
268
  ```
254
269
 
255
270
  _Parameters_
@@ -260,7 +275,7 @@ _Returns_
260
275
 
261
276
  - `string|void`: The query string part of the URL.
262
277
 
263
- <a name="hasQueryArg" href="#hasQueryArg">#</a> **hasQueryArg**
278
+ ### hasQueryArg
264
279
 
265
280
  Determines whether the URL contains a given query arg.
266
281
 
@@ -279,7 +294,7 @@ _Returns_
279
294
 
280
295
  - `boolean`: Whether or not the URL contains the query arg.
281
296
 
282
- <a name="isEmail" href="#isEmail">#</a> **isEmail**
297
+ ### isEmail
283
298
 
284
299
  Determines whether the given string looks like an email.
285
300
 
@@ -297,7 +312,7 @@ _Returns_
297
312
 
298
313
  - `boolean`: Whether or not it looks like an email.
299
314
 
300
- <a name="isURL" href="#isURL">#</a> **isURL**
315
+ ### isURL
301
316
 
302
317
  Determines whether the given string looks like a URL.
303
318
 
@@ -320,7 +335,7 @@ _Returns_
320
335
 
321
336
  - `boolean`: Whether or not it looks like a URL.
322
337
 
323
- <a name="isValidAuthority" href="#isValidAuthority">#</a> **isValidAuthority**
338
+ ### isValidAuthority
324
339
 
325
340
  Checks for invalid characters within the provided authority.
326
341
 
@@ -339,7 +354,7 @@ _Returns_
339
354
 
340
355
  - `boolean`: True if the argument contains a valid authority.
341
356
 
342
- <a name="isValidFragment" href="#isValidFragment">#</a> **isValidFragment**
357
+ ### isValidFragment
343
358
 
344
359
  Checks for invalid characters within the provided fragment.
345
360
 
@@ -358,7 +373,7 @@ _Returns_
358
373
 
359
374
  - `boolean`: True if the argument contains a valid fragment.
360
375
 
361
- <a name="isValidPath" href="#isValidPath">#</a> **isValidPath**
376
+ ### isValidPath
362
377
 
363
378
  Checks for invalid characters within the provided path.
364
379
 
@@ -377,7 +392,7 @@ _Returns_
377
392
 
378
393
  - `boolean`: True if the argument contains a valid path
379
394
 
380
- <a name="isValidProtocol" href="#isValidProtocol">#</a> **isValidProtocol**
395
+ ### isValidProtocol
381
396
 
382
397
  Tests if a url protocol is valid.
383
398
 
@@ -396,7 +411,7 @@ _Returns_
396
411
 
397
412
  - `boolean`: True if the argument is a valid protocol (e.g. http\:, tel:).
398
413
 
399
- <a name="isValidQueryString" href="#isValidQueryString">#</a> **isValidQueryString**
414
+ ### isValidQueryString
400
415
 
401
416
  Checks for invalid characters within the provided query string.
402
417
 
@@ -415,7 +430,7 @@ _Returns_
415
430
 
416
431
  - `boolean`: True if the argument contains a valid query string.
417
432
 
418
- <a name="prependHTTP" href="#prependHTTP">#</a> **prependHTTP**
433
+ ### prependHTTP
419
434
 
420
435
  Prepends "http\://" to a url, if it looks like something that is meant to be a TLD.
421
436
 
@@ -433,14 +448,18 @@ _Returns_
433
448
 
434
449
  - `string`: The updated URL.
435
450
 
436
- <a name="removeQueryArgs" href="#removeQueryArgs">#</a> **removeQueryArgs**
451
+ ### removeQueryArgs
437
452
 
438
453
  Removes arguments from the query string of the url
439
454
 
440
455
  _Usage_
441
456
 
442
457
  ```js
443
- const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=foobar', 'foo', 'bar' ); // https://wordpress.org?baz=foobar
458
+ const newUrl = removeQueryArgs(
459
+ 'https://wordpress.org?foo=bar&bar=baz&baz=foobar',
460
+ 'foo',
461
+ 'bar'
462
+ ); // https://wordpress.org?baz=foobar
444
463
  ```
445
464
 
446
465
  _Parameters_
@@ -452,7 +471,7 @@ _Returns_
452
471
 
453
472
  - `string`: Updated URL.
454
473
 
455
- <a name="safeDecodeURI" href="#safeDecodeURI">#</a> **safeDecodeURI**
474
+ ### safeDecodeURI
456
475
 
457
476
  Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
458
477
  `decodeURI` throws an error.
@@ -471,7 +490,7 @@ _Returns_
471
490
 
472
491
  - `string`: Decoded URI if possible.
473
492
 
474
- <a name="safeDecodeURIComponent" href="#safeDecodeURIComponent">#</a> **safeDecodeURIComponent**
493
+ ### safeDecodeURIComponent
475
494
 
476
495
  Safely decodes a URI component with `decodeURIComponent`. Returns the URI component unmodified if
477
496
  `decodeURIComponent` throws an error.
@@ -484,7 +503,6 @@ _Returns_
484
503
 
485
504
  - `string`: Decoded URI component if possible.
486
505
 
487
-
488
506
  <!-- END TOKEN(Autogenerated API docs) -->
489
507
 
490
508
  <br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
@@ -36,9 +36,10 @@ function setPath(object, path, value) {
36
36
  // If key is empty string and next value is array, derive key from
37
37
  // the current length of the array.
38
38
  key = object.length.toString();
39
- } // If the next key in the path is numeric (or empty string), it will be
40
- // created as an array. Otherwise, it will be created as an object.
39
+ }
41
40
 
41
+ key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be
42
+ // created as an array. Otherwise, it will be created as an object.
42
43
 
43
44
  const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
44
45
  object[key] = i === lastIndex ? // If at end of path, assign the intended value.
@@ -89,6 +90,6 @@ function getQueryArgs(url) {
89
90
  }
90
91
 
91
92
  return accumulator;
92
- }, {});
93
+ }, Object.create(null));
93
94
  }
94
95
  //# 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;;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,MAAlB,EAA0BC,IAA1B,EAAgCC,KAAhC,EAAwC;AACvC,QAAMC,MAAM,GAAGF,IAAI,CAACE,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AeC,QAAf,KAA6B;AACrC,UAAM,CAAEb,GAAF,EAAOJ,KAAK,GAAG,EAAf,IAAsBiB,QAAQ,CAClCH,KAD0B,CACnB,GADmB,EAE3B;AACA;AAH2B,KAI1BI,MAJ0B,CAIlBC,OAJkB,EAK1BC,GAL0B,CAKrBC,kBALqB,CAA5B;;AAOA,QAAKjB,GAAL,EAAW;AACV,YAAMkB,QAAQ,GAAGlB,GAAG,CAACS,OAAJ,CAAa,KAAb,EAAoB,EAApB,EAAyBC,KAAzB,CAAgC,GAAhC,CAAjB;AACAjB,MAAAA,OAAO,CAAEmB,WAAF,EAAeM,QAAf,EAAyBtB,KAAzB,CAAP;AACA;;AAED,WAAOgB,WAAP;AACA,GArBF,EAqBI,EArBJ,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\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}, {} )\n\t);\n}\n"]}
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","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;AAAX,OAAhB;AACA,KA7BiC,CA+BlC;;;AACAN,IAAAA,MAAM,GAAGA,MAAM,CAAEM,GAAF,CAAf;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASS,YAAT,CAAuBC,GAAvB,EAA6B;AACnC,SACC,CAAE,oCAAgBA,GAAhB,KAAyB,EAA3B,GACC;AACA;AACA;AACA;AACCC,EAAAA,OALF,CAKW,KALX,EAKkB,KALlB,EAMEC,KANF,CAMS,GANT,EAOEC,MAPF,CAOU,CAAEC,WAAF,EAAeC,QAAf,KAA6B;AACrC,UAAM,CAAEf,GAAF,EAAOJ,KAAK,GAAG,EAAf,IAAsBmB,QAAQ,CAClCH,KAD0B,CACnB,GADmB,EAE3B;AACA;AAH2B,KAI1BI,MAJ0B,CAIlBC,OAJkB,EAK1BC,GAL0B,CAKrBC,kBALqB,CAA5B;;AAOA,QAAKnB,GAAL,EAAW;AACV,YAAMoB,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"]}
@@ -28,9 +28,10 @@ function setPath(object, path, value) {
28
28
  // If key is empty string and next value is array, derive key from
29
29
  // the current length of the array.
30
30
  key = object.length.toString();
31
- } // If the next key in the path is numeric (or empty string), it will be
32
- // created as an array. Otherwise, it will be created as an object.
31
+ }
33
32
 
33
+ key = ['__proto__', 'constructor', 'prototype'].includes(key) ? key.toUpperCase() : key; // If the next key in the path is numeric (or empty string), it will be
34
+ // created as an array. Otherwise, it will be created as an object.
34
35
 
35
36
  const isNextKeyArrayIndex = !isNaN(Number(path[i + 1]));
36
37
  object[key] = i === lastIndex ? // If at end of path, assign the intended value.
@@ -81,6 +82,6 @@ export function getQueryArgs(url) {
81
82
  }
82
83
 
83
84
  return accumulator;
84
- }, {});
85
+ }, Object.create(null));
85
86
  }
86
87
  //# 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,QAAM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CAMS,GANT,EAOEC,MAPF,CAOU,CAAEC,WAAF,EAAeC,QAAf,KAA6B;AACrC,UAAM,CAAEb,GAAF,EAAOJ,KAAK,GAAG,EAAf,IAAsBiB,QAAQ,CAClCH,KAD0B,CACnB,GADmB,EAE3B;AACA;AAH2B,KAI1BI,MAJ0B,CAIlBC,OAJkB,EAK1BC,GAL0B,CAKrBC,kBALqB,CAA5B;;AAOA,QAAKjB,GAAL,EAAW;AACV,YAAMkB,QAAQ,GAAGlB,GAAG,CAACS,OAAJ,CAAa,KAAb,EAAoB,EAApB,EAAyBC,KAAzB,CAAgC,GAAhC,CAAjB;AACAjB,MAAAA,OAAO,CAAEmB,WAAF,EAAeM,QAAf,EAAyBtB,KAAzB,CAAP;AACA;;AAED,WAAOgB,WAAP;AACA,GArBF,EAqBI,EArBJ,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\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}, {} )\n\t);\n}\n"]}
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,QAAMC,MAAM,GAAGF,IAAI,CAACE,MAApB;AACA,QAAMC,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;;AAEDH,IAAAA,GAAG,GAAG,CAAE,WAAF,EAAe,aAAf,EAA8B,WAA9B,EAA4CI,QAA5C,CAAsDJ,GAAtD,IACHA,GAAG,CAACK,WAAJ,EADG,GAEHL,GAFH,CATkC,CAalC;AACA;;AACA,UAAMM,mBAAmB,GAAG,CAAEC,KAAK,CAAEC,MAAM,CAAEb,IAAI,CAAEI,CAAC,GAAG,CAAN,CAAN,CAAR,CAAnC;AAEAL,IAAAA,MAAM,CAAEM,GAAF,CAAN,GACCD,CAAC,KAAKD,SAAN,GACG;AACAF,IAAAA,KAFH,GAGG;AACA;AACAF,IAAAA,MAAM,CAAEM,GAAF,CAAN,KAAmBM,mBAAmB,GAAG,EAAH,GAAQ,EAA9C,CANJ;;AAQA,QAAKL,KAAK,CAACC,OAAN,CAAeR,MAAM,CAAEM,GAAF,CAArB,KAAkC,CAAEM,mBAAzC,EAA+D;AAC9D;AACA;AACAZ,MAAAA,MAAM,CAAEM,GAAF,CAAN,GAAgB,EAAE,GAAGN,MAAM,CAAEM,GAAF;AAAX,OAAhB;AACA,KA7BiC,CA+BlC;;;AACAN,IAAAA,MAAM,GAAGA,MAAM,CAAEM,GAAF,CAAf;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASS,YAAT,CAAuBC,GAAvB,EAA6B;AACnC,SACC,CAAElB,cAAc,CAAEkB,GAAF,CAAd,IAAyB,EAA3B,GACC;AACA;AACA;AACA;AACCC,EAAAA,OALF,CAKW,KALX,EAKkB,KALlB,EAMEC,KANF,CAMS,GANT,EAOEC,MAPF,CAOU,CAAEC,WAAF,EAAeC,QAAf,KAA6B;AACrC,UAAM,CAAEf,GAAF,EAAOJ,KAAK,GAAG,EAAf,IAAsBmB,QAAQ,CAClCH,KAD0B,CACnB,GADmB,EAE3B;AACA;AAH2B,KAI1BI,MAJ0B,CAIlBC,OAJkB,EAK1BC,GAL0B,CAKrBC,kBALqB,CAA5B;;AAOA,QAAKnB,GAAL,EAAW;AACV,YAAMoB,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-args.d.ts","sourceRoot":"","sources":["../src/get-query-args.js"],"names":[],"mappings":"AAsDA;;;;;;;;;;;;;GAaG;AACH,kCAVW,MAAM,GAQL,SAAS,CA2BpB"}
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": "3.1.0",
3
+ "version": "3.1.3",
4
4
  "description": "WordPress URL utilities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -34,5 +34,5 @@
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "24ad588cb6ea6fc2a654b5e1cc0764726771698a"
37
+ "gitHead": "6464883c6c546233543a1ee01428059dee3560fc"
38
38
  }
@@ -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
  }
@@ -227,7 +227,7 @@
227
227
  "affectsGlobalScope": false
228
228
  },
229
229
  "./src/get-query-args.js": {
230
- "version": "c1707eb8fe5c7af9446740e91d599de82da8e8c5a478b20ad19e3a18a0691feb",
230
+ "version": "7bb4d57a1385212fb584dbf91a55fd4b82a88dedd8a73d40a4d6199155f404d5",
231
231
  "signature": "d24b1424b4a4a0f2cc08685bdead834018bf5bdd4de1fd8b3c44648b8fd4e2f3",
232
232
  "affectsGlobalScope": false
233
233
  },