hono 4.13.7 → 4.13.8
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 +1 -1
- package/dist/adapter/aws-lambda/handler.js +5 -4
- package/dist/cjs/adapter/aws-lambda/handler.js +5 -4
- package/dist/cjs/context.js +1 -1
- package/dist/cjs/helper/accepts/accepts.js +1 -1
- package/dist/cjs/jsx/dom/render.js +44 -8
- package/dist/cjs/middleware/language/language.js +4 -1
- package/dist/cjs/request.js +4 -1
- package/dist/cjs/utils/accept.js +4 -7
- package/dist/context.js +1 -1
- package/dist/helper/accepts/accepts.js +1 -1
- package/dist/jsx/dom/render.js +44 -8
- package/dist/middleware/language/language.js +4 -1
- package/dist/request.js +4 -1
- package/dist/types/helper/proxy/index.d.ts +1 -1
- package/dist/types/helper/route/index.d.ts +2 -2
- package/dist/types/middleware/combine/index.d.ts +3 -1
- package/dist/types/utils/types.d.ts +1 -1
- package/dist/utils/accept.js +4 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Contributions Welcome! You can contribute in the following ways.
|
|
|
64
64
|
|
|
65
65
|
- Create an Issue - Propose a new feature. Report a bug.
|
|
66
66
|
- Pull Request - Fix a bug or typo. Refactor the code.
|
|
67
|
-
- Create third-party middleware - See
|
|
67
|
+
- Create third-party middleware - See [Third-party middleware](docs/CONTRIBUTING.md#third-party-middleware).
|
|
68
68
|
- Share - Share your thoughts on the Blog, X, and others.
|
|
69
69
|
- Make your application - Please try to use Hono.
|
|
70
70
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/adapter/aws-lambda/handler.ts
|
|
2
|
+
import { pipeline } from "node:stream/promises";
|
|
2
3
|
import { decodeBase64, encodeBase64 } from "../../utils/encode.js";
|
|
3
4
|
function sanitizeHeaderValue(value) {
|
|
4
5
|
const hasNonAscii = /[^\x00-\x7F]/.test(value);
|
|
@@ -10,14 +11,14 @@ function sanitizeHeaderValue(value) {
|
|
|
10
11
|
var getRequestContext = (event) => {
|
|
11
12
|
return event.requestContext;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
+
async function* readWebStream(reader) {
|
|
14
15
|
let readResult = await reader.read();
|
|
15
16
|
while (!readResult.done) {
|
|
16
|
-
|
|
17
|
+
yield readResult.value;
|
|
17
18
|
readResult = await reader.read();
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
}
|
|
21
|
+
var streamToNodeStream = (reader, writer) => pipeline(readWebStream(reader), writer);
|
|
21
22
|
var streamHandle = (app) => {
|
|
22
23
|
return awslambda.streamifyResponse(
|
|
23
24
|
async (event, responseStream, context) => {
|
|
@@ -29,6 +29,7 @@ __export(handler_exports, {
|
|
|
29
29
|
streamHandle: () => streamHandle
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(handler_exports);
|
|
32
|
+
var import_promises = require("node:stream/promises");
|
|
32
33
|
var import_encode = require("../../utils/encode");
|
|
33
34
|
function sanitizeHeaderValue(value) {
|
|
34
35
|
const hasNonAscii = /[^\x00-\x7F]/.test(value);
|
|
@@ -40,14 +41,14 @@ function sanitizeHeaderValue(value) {
|
|
|
40
41
|
const getRequestContext = (event) => {
|
|
41
42
|
return event.requestContext;
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
+
async function* readWebStream(reader) {
|
|
44
45
|
let readResult = await reader.read();
|
|
45
46
|
while (!readResult.done) {
|
|
46
|
-
|
|
47
|
+
yield readResult.value;
|
|
47
48
|
readResult = await reader.read();
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
}
|
|
51
|
+
const streamToNodeStream = (reader, writer) => (0, import_promises.pipeline)(readWebStream(reader), writer);
|
|
51
52
|
const streamHandle = (app) => {
|
|
52
53
|
return awslambda.streamifyResponse(
|
|
53
54
|
async (event, responseStream, context) => {
|
package/dist/cjs/context.js
CHANGED
|
@@ -424,7 +424,7 @@ class Context {
|
|
|
424
424
|
const locationString = String(location);
|
|
425
425
|
this.header(
|
|
426
426
|
"Location",
|
|
427
|
-
//
|
|
427
|
+
// Multibytes should be encoded
|
|
428
428
|
// eslint-disable-next-line no-control-regex
|
|
429
429
|
!/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
|
|
430
430
|
);
|
|
@@ -47,7 +47,7 @@ const getSpecificity = (type) => {
|
|
|
47
47
|
};
|
|
48
48
|
const defaultMatch = (accepts2, config) => {
|
|
49
49
|
const { supports, default: defaultSupport } = config;
|
|
50
|
-
const sortedAccepts = accepts2.
|
|
50
|
+
const sortedAccepts = accepts2.filter((accept) => accept.q > 0).sort((a, b) => {
|
|
51
51
|
if (b.q !== a.q) {
|
|
52
52
|
return b.q - a.q;
|
|
53
53
|
}
|
|
@@ -355,6 +355,17 @@ const applyNodeObject = (node, container, isNew) => {
|
|
|
355
355
|
}
|
|
356
356
|
};
|
|
357
357
|
const isSameContext = (oldContexts, newContexts) => !!(oldContexts && oldContexts.length === newContexts.length && oldContexts.every((ctx, i) => ctx[1] === newContexts[i][1]));
|
|
358
|
+
const indexChildrenByKey = (children) => {
|
|
359
|
+
const index = /* @__PURE__ */ new Map();
|
|
360
|
+
for (const child of children) {
|
|
361
|
+
const key = child.key;
|
|
362
|
+
if (index.has(key)) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
index.set(key, child);
|
|
366
|
+
}
|
|
367
|
+
return index;
|
|
368
|
+
};
|
|
358
369
|
const fallbackUpdateFnArrayMap = /* @__PURE__ */ new WeakMap();
|
|
359
370
|
const build = (context, node, children) => {
|
|
360
371
|
const buildWithPreviousChildren = !children && node.pC;
|
|
@@ -368,9 +379,11 @@ const build = (context, node, children) => {
|
|
|
368
379
|
foundErrorHandler = children[0][import_constants.DOM_ERROR_HANDLER];
|
|
369
380
|
context[5].push([context, foundErrorHandler, node]);
|
|
370
381
|
}
|
|
371
|
-
|
|
382
|
+
let oldVChildren = buildWithPreviousChildren ? [...node.pC] : node.vC ? [...node.vC] : void 0;
|
|
372
383
|
const vChildren = [];
|
|
373
384
|
let prevNode;
|
|
385
|
+
let scanBudget = (oldVChildren?.length || 0) * 2;
|
|
386
|
+
let oldChildrenByKey;
|
|
374
387
|
for (let i = 0; i < children.length; i++) {
|
|
375
388
|
if (Array.isArray(children[i])) {
|
|
376
389
|
children.splice(i, 1, ...children[i].flat(Infinity));
|
|
@@ -389,13 +402,35 @@ const build = (context, node, children) => {
|
|
|
389
402
|
}
|
|
390
403
|
}
|
|
391
404
|
let oldChild;
|
|
392
|
-
if (
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
405
|
+
if (oldChildrenByKey && child.key === void 0 && !isNodeString(child)) {
|
|
406
|
+
oldVChildren = [...oldChildrenByKey.values()];
|
|
407
|
+
oldChildrenByKey = void 0;
|
|
408
|
+
}
|
|
409
|
+
if (oldChildrenByKey) {
|
|
410
|
+
const key = child.key;
|
|
411
|
+
const candidate = oldChildrenByKey.get(key);
|
|
412
|
+
if (candidate && (isNodeString(child) ? isNodeString(candidate) : candidate.tag === child.tag && candidate.key === key)) {
|
|
413
|
+
oldChild = candidate;
|
|
414
|
+
oldChildrenByKey.delete(key);
|
|
415
|
+
}
|
|
416
|
+
} else if (oldVChildren && oldVChildren.length) {
|
|
417
|
+
const first = oldVChildren[0];
|
|
418
|
+
const isMatchFirst = isNodeString(child) ? isNodeString(first) : !isNodeString(first) && (child.key !== void 0 ? first.key === child.key && first.tag === child.tag : first.tag === child.tag);
|
|
419
|
+
if (isMatchFirst) {
|
|
420
|
+
oldChild = oldVChildren.shift();
|
|
421
|
+
} else {
|
|
422
|
+
const i2 = oldVChildren.findIndex(
|
|
423
|
+
isNodeString(child) ? (c) => isNodeString(c) : child.key !== void 0 ? (c) => c.key === child.key && c.tag === child.tag : (c) => c.tag === child.tag
|
|
424
|
+
);
|
|
425
|
+
scanBudget -= i2 === -1 ? oldVChildren.length : i2;
|
|
426
|
+
if (i2 !== -1) {
|
|
427
|
+
oldChild = oldVChildren[i2];
|
|
428
|
+
oldVChildren.splice(i2, 1);
|
|
429
|
+
}
|
|
430
|
+
if (scanBudget < 0) {
|
|
431
|
+
scanBudget = Infinity;
|
|
432
|
+
oldChildrenByKey = indexChildrenByKey(oldVChildren);
|
|
433
|
+
}
|
|
399
434
|
}
|
|
400
435
|
}
|
|
401
436
|
if (oldChild) {
|
|
@@ -441,6 +476,7 @@ const build = (context, node, children) => {
|
|
|
441
476
|
prevNode = child;
|
|
442
477
|
}
|
|
443
478
|
}
|
|
479
|
+
oldVChildren = oldChildrenByKey ? [...oldChildrenByKey.values()] : oldVChildren;
|
|
444
480
|
node.vR = buildWithPreviousChildren ? [...node.vC, ...oldVChildren || []] : oldVChildren || [];
|
|
445
481
|
node.vC = vChildren;
|
|
446
482
|
if (buildWithPreviousChildren) {
|
|
@@ -101,7 +101,10 @@ function detectFromHeader(c, options) {
|
|
|
101
101
|
return void 0;
|
|
102
102
|
}
|
|
103
103
|
const languages = parseAcceptLanguage(acceptLanguage);
|
|
104
|
-
for (const { lang } of languages) {
|
|
104
|
+
for (const { lang, q } of languages) {
|
|
105
|
+
if (q === 0) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
105
108
|
const normalizedLang = normalizeLanguage(lang, options);
|
|
106
109
|
if (normalizedLang) {
|
|
107
110
|
return normalizedLang;
|
package/dist/cjs/request.js
CHANGED
|
@@ -116,7 +116,10 @@ class HonoRequest {
|
|
|
116
116
|
if (anyCachedKey === "json") {
|
|
117
117
|
body = JSON.stringify(body);
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
const contentType = anyCachedKey === "formData" ? void 0 : raw.headers.get("content-type");
|
|
120
|
+
return new Response(body, {
|
|
121
|
+
headers: contentType ? { "Content-Type": contentType } : void 0
|
|
122
|
+
})[key]();
|
|
120
123
|
});
|
|
121
124
|
}
|
|
122
125
|
return bodyCache[key] = raw[key]();
|
package/dist/cjs/utils/accept.js
CHANGED
|
@@ -201,7 +201,7 @@ const parseAccept = (acceptHeader) => {
|
|
|
201
201
|
;
|
|
202
202
|
[i, accept] = getNextAcceptValue(acceptHeader, i);
|
|
203
203
|
if (accept) {
|
|
204
|
-
accept.q = parseQuality(accept.params.q);
|
|
204
|
+
accept.q = parseQuality(accept.params.q ?? accept.params.Q);
|
|
205
205
|
values.push(accept);
|
|
206
206
|
if (lastAccept && lastAccept.q < accept.q) {
|
|
207
207
|
requiresSort = true;
|
|
@@ -225,16 +225,13 @@ const parseQuality = (qVal) => {
|
|
|
225
225
|
return 0;
|
|
226
226
|
}
|
|
227
227
|
const num = Number(qVal);
|
|
228
|
-
if (num
|
|
228
|
+
if (Number.isNaN(num)) {
|
|
229
229
|
return 1;
|
|
230
230
|
}
|
|
231
|
-
if (num
|
|
231
|
+
if (num < 0) {
|
|
232
232
|
return 0;
|
|
233
233
|
}
|
|
234
|
-
if (
|
|
235
|
-
return 1;
|
|
236
|
-
}
|
|
237
|
-
if (num < 0 || num > 1) {
|
|
234
|
+
if (num > 1) {
|
|
238
235
|
return 1;
|
|
239
236
|
}
|
|
240
237
|
return num;
|
package/dist/context.js
CHANGED
|
@@ -402,7 +402,7 @@ var Context = class {
|
|
|
402
402
|
const locationString = String(location);
|
|
403
403
|
this.header(
|
|
404
404
|
"Location",
|
|
405
|
-
//
|
|
405
|
+
// Multibytes should be encoded
|
|
406
406
|
// eslint-disable-next-line no-control-regex
|
|
407
407
|
!/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
|
|
408
408
|
);
|
|
@@ -25,7 +25,7 @@ var getSpecificity = (type) => {
|
|
|
25
25
|
};
|
|
26
26
|
var defaultMatch = (accepts2, config) => {
|
|
27
27
|
const { supports, default: defaultSupport } = config;
|
|
28
|
-
const sortedAccepts = accepts2.
|
|
28
|
+
const sortedAccepts = accepts2.filter((accept) => accept.q > 0).sort((a, b) => {
|
|
29
29
|
if (b.q !== a.q) {
|
|
30
30
|
return b.q - a.q;
|
|
31
31
|
}
|
package/dist/jsx/dom/render.js
CHANGED
|
@@ -332,6 +332,17 @@ var applyNodeObject = (node, container, isNew) => {
|
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
334
|
var isSameContext = (oldContexts, newContexts) => !!(oldContexts && oldContexts.length === newContexts.length && oldContexts.every((ctx, i) => ctx[1] === newContexts[i][1]));
|
|
335
|
+
var indexChildrenByKey = (children) => {
|
|
336
|
+
const index = /* @__PURE__ */ new Map();
|
|
337
|
+
for (const child of children) {
|
|
338
|
+
const key = child.key;
|
|
339
|
+
if (index.has(key)) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
index.set(key, child);
|
|
343
|
+
}
|
|
344
|
+
return index;
|
|
345
|
+
};
|
|
335
346
|
var fallbackUpdateFnArrayMap = /* @__PURE__ */ new WeakMap();
|
|
336
347
|
var build = (context, node, children) => {
|
|
337
348
|
const buildWithPreviousChildren = !children && node.pC;
|
|
@@ -345,9 +356,11 @@ var build = (context, node, children) => {
|
|
|
345
356
|
foundErrorHandler = children[0][DOM_ERROR_HANDLER];
|
|
346
357
|
context[5].push([context, foundErrorHandler, node]);
|
|
347
358
|
}
|
|
348
|
-
|
|
359
|
+
let oldVChildren = buildWithPreviousChildren ? [...node.pC] : node.vC ? [...node.vC] : void 0;
|
|
349
360
|
const vChildren = [];
|
|
350
361
|
let prevNode;
|
|
362
|
+
let scanBudget = (oldVChildren?.length || 0) * 2;
|
|
363
|
+
let oldChildrenByKey;
|
|
351
364
|
for (let i = 0; i < children.length; i++) {
|
|
352
365
|
if (Array.isArray(children[i])) {
|
|
353
366
|
children.splice(i, 1, ...children[i].flat(Infinity));
|
|
@@ -366,13 +379,35 @@ var build = (context, node, children) => {
|
|
|
366
379
|
}
|
|
367
380
|
}
|
|
368
381
|
let oldChild;
|
|
369
|
-
if (
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
382
|
+
if (oldChildrenByKey && child.key === void 0 && !isNodeString(child)) {
|
|
383
|
+
oldVChildren = [...oldChildrenByKey.values()];
|
|
384
|
+
oldChildrenByKey = void 0;
|
|
385
|
+
}
|
|
386
|
+
if (oldChildrenByKey) {
|
|
387
|
+
const key = child.key;
|
|
388
|
+
const candidate = oldChildrenByKey.get(key);
|
|
389
|
+
if (candidate && (isNodeString(child) ? isNodeString(candidate) : candidate.tag === child.tag && candidate.key === key)) {
|
|
390
|
+
oldChild = candidate;
|
|
391
|
+
oldChildrenByKey.delete(key);
|
|
392
|
+
}
|
|
393
|
+
} else if (oldVChildren && oldVChildren.length) {
|
|
394
|
+
const first = oldVChildren[0];
|
|
395
|
+
const isMatchFirst = isNodeString(child) ? isNodeString(first) : !isNodeString(first) && (child.key !== void 0 ? first.key === child.key && first.tag === child.tag : first.tag === child.tag);
|
|
396
|
+
if (isMatchFirst) {
|
|
397
|
+
oldChild = oldVChildren.shift();
|
|
398
|
+
} else {
|
|
399
|
+
const i2 = oldVChildren.findIndex(
|
|
400
|
+
isNodeString(child) ? (c) => isNodeString(c) : child.key !== void 0 ? (c) => c.key === child.key && c.tag === child.tag : (c) => c.tag === child.tag
|
|
401
|
+
);
|
|
402
|
+
scanBudget -= i2 === -1 ? oldVChildren.length : i2;
|
|
403
|
+
if (i2 !== -1) {
|
|
404
|
+
oldChild = oldVChildren[i2];
|
|
405
|
+
oldVChildren.splice(i2, 1);
|
|
406
|
+
}
|
|
407
|
+
if (scanBudget < 0) {
|
|
408
|
+
scanBudget = Infinity;
|
|
409
|
+
oldChildrenByKey = indexChildrenByKey(oldVChildren);
|
|
410
|
+
}
|
|
376
411
|
}
|
|
377
412
|
}
|
|
378
413
|
if (oldChild) {
|
|
@@ -418,6 +453,7 @@ var build = (context, node, children) => {
|
|
|
418
453
|
prevNode = child;
|
|
419
454
|
}
|
|
420
455
|
}
|
|
456
|
+
oldVChildren = oldChildrenByKey ? [...oldChildrenByKey.values()] : oldVChildren;
|
|
421
457
|
node.vR = buildWithPreviousChildren ? [...node.vC, ...oldVChildren || []] : oldVChildren || [];
|
|
422
458
|
node.vC = vChildren;
|
|
423
459
|
if (buildWithPreviousChildren) {
|
|
@@ -71,7 +71,10 @@ function detectFromHeader(c, options) {
|
|
|
71
71
|
return void 0;
|
|
72
72
|
}
|
|
73
73
|
const languages = parseAcceptLanguage(acceptLanguage);
|
|
74
|
-
for (const { lang } of languages) {
|
|
74
|
+
for (const { lang, q } of languages) {
|
|
75
|
+
if (q === 0) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
75
78
|
const normalizedLang = normalizeLanguage(lang, options);
|
|
76
79
|
if (normalizedLang) {
|
|
77
80
|
return normalizedLang;
|
package/dist/request.js
CHANGED
|
@@ -94,7 +94,10 @@ var HonoRequest = class {
|
|
|
94
94
|
if (anyCachedKey === "json") {
|
|
95
95
|
body = JSON.stringify(body);
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
const contentType = anyCachedKey === "formData" ? void 0 : raw.headers.get("content-type");
|
|
98
|
+
return new Response(body, {
|
|
99
|
+
headers: contentType ? { "Content-Type": contentType } : void 0
|
|
100
|
+
})[key]();
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
return bodyCache[key] = raw[key]();
|
|
@@ -27,7 +27,7 @@ interface ProxyFetch {
|
|
|
27
27
|
* Fetch API wrapper for proxy.
|
|
28
28
|
* The parameters and return value are the same as for `fetch` (except for the proxy-specific options).
|
|
29
29
|
*
|
|
30
|
-
* The
|
|
30
|
+
* The "Accept-Encoding" header is replaced with an encoding that the current runtime can handle.
|
|
31
31
|
* Unnecessary response headers are deleted and a Response object is returned that can be returned
|
|
32
32
|
* as is as a response from the handler.
|
|
33
33
|
*
|
|
@@ -31,7 +31,7 @@ export declare const matchedRoutes: (c: Context) => RouterRoute[];
|
|
|
31
31
|
* Get the route path registered within the handler
|
|
32
32
|
*
|
|
33
33
|
* @param {Context} c - The context object
|
|
34
|
-
* @param {number} index - The index of the
|
|
34
|
+
* @param {number} index - The index of the route from which to retrieve the path, similar to Array.prototype.at(), where a negative number is the index counted from the end of the matching route. Defaults to the current route index.
|
|
35
35
|
* @returns The route path registered within the handler
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
@@ -54,7 +54,7 @@ export declare const routePath: (c: Context, index?: number) => string;
|
|
|
54
54
|
* Get the basePath of the as-is route specified by routing.
|
|
55
55
|
*
|
|
56
56
|
* @param {Context} c - The context object
|
|
57
|
-
* @param {number} index - The index of the
|
|
57
|
+
* @param {number} index - The index of the route from which to retrieve the path, similar to Array.prototype.at(), where a negative number is the index counted from the end of the matching route. Defaults to the current route index.
|
|
58
58
|
* @returns The basePath of the as-is route specified by routing.
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
@@ -66,7 +66,9 @@ export declare const every: (...middleware: (MiddlewareHandler | Condition)[]) =
|
|
|
66
66
|
* If there are multiple targets to match any of them, they can be passed as an array.
|
|
67
67
|
* If a string is passed, it will be treated as a path pattern to match.
|
|
68
68
|
* If a Condition function is passed, it will be evaluated against the request context.
|
|
69
|
-
* @param middleware -
|
|
69
|
+
* @param middleware - Middleware to run when the condition is not met.
|
|
70
|
+
* Multiple middleware can be passed, and they are applied in the order they are passed.
|
|
71
|
+
* @returns A composed middleware.
|
|
70
72
|
*
|
|
71
73
|
* @example
|
|
72
74
|
* ```ts
|
|
@@ -32,7 +32,7 @@ export type JSONValue = JSONObject | JSONArray | JSONPrimitive;
|
|
|
32
32
|
* `JSON.stringify()` throws a `TypeError` when it encounters a `bigint` value,
|
|
33
33
|
* unless a custom `replacer` function or `.toJSON()` method is provided.
|
|
34
34
|
*
|
|
35
|
-
* This
|
|
35
|
+
* This behavior can be controlled by the `TError` generic type parameter,
|
|
36
36
|
* which defaults to `bigint | ReadonlyArray<bigint>`.
|
|
37
37
|
* You can set it to `never` to disable this check.
|
|
38
38
|
*/
|
package/dist/utils/accept.js
CHANGED
|
@@ -180,7 +180,7 @@ var parseAccept = (acceptHeader) => {
|
|
|
180
180
|
;
|
|
181
181
|
[i, accept] = getNextAcceptValue(acceptHeader, i);
|
|
182
182
|
if (accept) {
|
|
183
|
-
accept.q = parseQuality(accept.params.q);
|
|
183
|
+
accept.q = parseQuality(accept.params.q ?? accept.params.Q);
|
|
184
184
|
values.push(accept);
|
|
185
185
|
if (lastAccept && lastAccept.q < accept.q) {
|
|
186
186
|
requiresSort = true;
|
|
@@ -204,16 +204,13 @@ var parseQuality = (qVal) => {
|
|
|
204
204
|
return 0;
|
|
205
205
|
}
|
|
206
206
|
const num = Number(qVal);
|
|
207
|
-
if (num
|
|
207
|
+
if (Number.isNaN(num)) {
|
|
208
208
|
return 1;
|
|
209
209
|
}
|
|
210
|
-
if (num
|
|
210
|
+
if (num < 0) {
|
|
211
211
|
return 0;
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
214
|
-
return 1;
|
|
215
|
-
}
|
|
216
|
-
if (num < 0 || num > 1) {
|
|
213
|
+
if (num > 1) {
|
|
217
214
|
return 1;
|
|
218
215
|
}
|
|
219
216
|
return num;
|