@nxtedition/lib 23.7.4 → 23.7.6
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/http.js +40 -6
- package/package.json +2 -2
package/http.js
CHANGED
|
@@ -8,6 +8,7 @@ import compose from 'koa-compose'
|
|
|
8
8
|
import http from 'http'
|
|
9
9
|
import fp from 'lodash/fp.js'
|
|
10
10
|
import tp from 'timers/promises'
|
|
11
|
+
import querystring from 'fast-querystring'
|
|
11
12
|
|
|
12
13
|
export const kAbortController = Symbol('abortController')
|
|
13
14
|
|
|
@@ -133,6 +134,7 @@ export class Context {
|
|
|
133
134
|
return this.#req.query
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
this.#target ??= requestTarget(this.#req)
|
|
136
138
|
this.#query ??=
|
|
137
139
|
this.#target.search.length > 1
|
|
138
140
|
? Object.freeze(querystring.parse(this.#target.search.slice(1)))
|
|
@@ -350,10 +352,13 @@ export async function requestMiddleware(ctx, next) {
|
|
|
350
352
|
}
|
|
351
353
|
|
|
352
354
|
export class IncomingMessage extends http.IncomingMessage {
|
|
353
|
-
#target
|
|
354
355
|
#host
|
|
355
356
|
#url
|
|
356
357
|
#socket
|
|
358
|
+
#target
|
|
359
|
+
|
|
360
|
+
#search
|
|
361
|
+
#query
|
|
357
362
|
|
|
358
363
|
constructor(...args) {
|
|
359
364
|
super(...args)
|
|
@@ -369,13 +374,26 @@ export class IncomingMessage extends http.IncomingMessage {
|
|
|
369
374
|
this.#url !== this.url ||
|
|
370
375
|
this.#socket !== this.socket
|
|
371
376
|
) {
|
|
372
|
-
this.#
|
|
377
|
+
this.#socket = this.socket
|
|
373
378
|
this.#host = this.headers.host
|
|
374
379
|
this.#url = this.url
|
|
375
|
-
this.#
|
|
380
|
+
this.#target = undefined
|
|
376
381
|
}
|
|
382
|
+
|
|
377
383
|
return (this.#target ??= requestTarget(this))
|
|
378
384
|
}
|
|
385
|
+
|
|
386
|
+
get query() {
|
|
387
|
+
const search = this.target.search
|
|
388
|
+
|
|
389
|
+
if (this.#search !== search) {
|
|
390
|
+
this.#search = search
|
|
391
|
+
this.#query = undefined
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return (this.#query ??=
|
|
395
|
+
search.length > 1 ? Object.freeze(querystring.parse(search.slice(1))) : {})
|
|
396
|
+
}
|
|
379
397
|
}
|
|
380
398
|
|
|
381
399
|
export class ServerResponse extends http.ServerResponse {
|
|
@@ -478,10 +496,13 @@ export class ServerResponse extends http.ServerResponse {
|
|
|
478
496
|
}
|
|
479
497
|
|
|
480
498
|
export class Http2ServerRequest extends http2.Http2ServerRequest {
|
|
481
|
-
#target
|
|
482
499
|
#host
|
|
483
500
|
#url
|
|
484
501
|
#socket
|
|
502
|
+
#target
|
|
503
|
+
|
|
504
|
+
#search
|
|
505
|
+
#query
|
|
485
506
|
|
|
486
507
|
constructor(...args) {
|
|
487
508
|
super(...args)
|
|
@@ -497,13 +518,26 @@ export class Http2ServerRequest extends http2.Http2ServerRequest {
|
|
|
497
518
|
this.#url !== this.url ||
|
|
498
519
|
this.#socket !== this.socket
|
|
499
520
|
) {
|
|
500
|
-
this.#
|
|
521
|
+
this.#socket = this.socket
|
|
501
522
|
this.#host = this.headers.host
|
|
502
523
|
this.#url = this.url
|
|
503
|
-
this.#
|
|
524
|
+
this.#target = undefined
|
|
504
525
|
}
|
|
526
|
+
|
|
505
527
|
return (this.#target ??= requestTarget(this))
|
|
506
528
|
}
|
|
529
|
+
|
|
530
|
+
get query() {
|
|
531
|
+
const search = this.target.search
|
|
532
|
+
|
|
533
|
+
if (this.#search !== search) {
|
|
534
|
+
this.#search = search
|
|
535
|
+
this.#query = undefined
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return (this.#query ??=
|
|
539
|
+
search.length > 1 ? Object.freeze(querystring.parse(search.slice(1))) : {})
|
|
540
|
+
}
|
|
507
541
|
}
|
|
508
542
|
|
|
509
543
|
export class Http2ServerResponse extends http2.Http2ServerResponse {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "23.7.
|
|
3
|
+
"version": "23.7.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@swc/wasm-web": "^1.11.22",
|
|
73
73
|
"date-fns": "^4.1.0",
|
|
74
74
|
"diff": "5.2.0",
|
|
75
|
-
"fast-querystring": "^1.1.
|
|
75
|
+
"fast-querystring": "^1.1.2",
|
|
76
76
|
"hasha": "^6.0.0",
|
|
77
77
|
"http-errors": "^2.0.0",
|
|
78
78
|
"json5": "^2.2.3",
|