repocairn 0.1.2 → 0.1.4
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 +13 -2
- package/dist/graphify-source.d.ts +17 -0
- package/dist/graphify-source.js +87 -0
- package/dist/graphify-source.js.map +1 -0
- package/dist/index-command.js +3 -1
- package/dist/index-command.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/indexer.d.ts +1 -0
- package/dist/indexer.js +2 -1
- package/dist/indexer.js.map +1 -1
- package/dist/signals.d.ts +13 -0
- package/dist/signals.js +84 -0
- package/dist/signals.js.map +1 -0
- package/dist/tree-sitter-extract.js +134 -1
- package/dist/tree-sitter-extract.js.map +1 -1
- package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/eventsource-parser/dist/index.cjs +2 -2
- package/node_modules/eventsource-parser/dist/index.cjs.map +1 -1
- package/node_modules/eventsource-parser/dist/index.js +2 -2
- package/node_modules/eventsource-parser/dist/index.js.map +1 -1
- package/node_modules/eventsource-parser/package.json +1 -1
- package/node_modules/eventsource-parser/src/parse.ts +4 -2
- package/node_modules/express-rate-limit/dist/index.cjs +6 -1
- package/node_modules/express-rate-limit/dist/index.mjs +6 -1
- package/node_modules/express-rate-limit/package.json +6 -6
- package/node_modules/fast-uri/index.js +37 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +136 -0
- package/node_modules/hono/dist/cjs/client/client.js +3 -3
- package/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +32 -13
- package/node_modules/hono/dist/cjs/helper/proxy/index.js +4 -0
- package/node_modules/hono/dist/cjs/hono-base.js +3 -2
- package/node_modules/hono/dist/cjs/jsx/base.js +27 -23
- package/node_modules/hono/dist/cjs/jsx/hooks/index.js +16 -13
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +17 -14
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +6 -3
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/language/language.js +10 -6
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +90 -0
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/cjs/request.js +6 -8
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +44 -68
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/cjs/router.js +1 -1
- package/node_modules/hono/dist/cjs/utils/cookie.js +3 -2
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/cjs/utils/stream.js +5 -2
- package/node_modules/hono/dist/cjs/utils/url.js +9 -9
- package/node_modules/hono/dist/client/client.js +3 -3
- package/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/hono/dist/context.js +32 -13
- package/node_modules/hono/dist/helper/proxy/index.js +4 -0
- package/node_modules/hono/dist/hono-base.js +3 -2
- package/node_modules/hono/dist/jsx/base.js +27 -23
- package/node_modules/hono/dist/jsx/hooks/index.js +16 -13
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/middleware/cors/index.js +17 -14
- package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/middleware/etag/index.js +6 -3
- package/node_modules/hono/dist/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/middleware/language/language.js +10 -6
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +68 -0
- package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/request.js +7 -9
- package/node_modules/hono/dist/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/router/trie-router/node.js +44 -68
- package/node_modules/hono/dist/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/router.js +1 -1
- package/node_modules/hono/dist/types/client/types.d.ts +1 -1
- package/node_modules/hono/dist/types/context.d.ts +4 -0
- package/node_modules/hono/dist/types/hono-base.d.ts +4 -3
- package/node_modules/hono/dist/types/jsx/base.d.ts +4 -2
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +8 -6
- package/node_modules/hono/dist/types/jsx/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/cache/index.d.ts +6 -4
- package/node_modules/hono/dist/types/middleware/cors/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
- package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +49 -0
- package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +1 -1
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +2 -1
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
- package/node_modules/hono/dist/types/router.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/headers.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/cookie.js +4 -3
- package/node_modules/hono/dist/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/utils/stream.js +5 -2
- package/node_modules/hono/dist/utils/url.js +7 -8
- package/node_modules/hono/package.json +10 -3
- package/node_modules/ip-address/README.md +163 -149
- package/node_modules/ip-address/dist/address-error.d.ts +11 -0
- package/node_modules/ip-address/dist/address-error.js.map +1 -1
- package/node_modules/ip-address/dist/common.d.ts +6 -0
- package/node_modules/ip-address/dist/common.js +17 -1
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv4.d.ts +22 -6
- package/node_modules/ip-address/dist/ipv4.js +25 -18
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.d.ts +19 -5
- package/node_modules/ip-address/dist/ipv6.js +61 -33
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/package.json +5 -3
- package/node_modules/jose/README.md +13 -13
- package/node_modules/jose/dist/types/index.d.ts +6 -5
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +8 -19
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +8 -19
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +18 -13
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +21 -21
- package/node_modules/jose/dist/types/jwk/embedded.d.ts +8 -12
- package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +0 -15
- package/node_modules/jose/dist/types/jwks/local.d.ts +12 -21
- package/node_modules/jose/dist/types/jwks/remote.d.ts +34 -165
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +17 -13
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +16 -17
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +18 -15
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +17 -11
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +11 -34
- package/node_modules/jose/dist/types/jwt/sign.d.ts +2 -13
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +4 -13
- package/node_modules/jose/dist/types/jwt/verify.d.ts +14 -13
- package/node_modules/jose/dist/types/key/export.d.ts +0 -14
- package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +7 -14
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +16 -14
- package/node_modules/jose/dist/types/key/import.d.ts +18 -28
- package/node_modules/jose/dist/types/types.d.ts +243 -224
- package/node_modules/jose/dist/types/util/base64url.d.ts +11 -4
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -9
- package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +0 -8
- package/node_modules/jose/dist/types/util/errors.d.ts +128 -121
- package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +4 -22
- package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +5 -153
- package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +16 -111
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +23 -3
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +70 -82
- package/node_modules/jose/dist/webapi/jwk/embedded.js +5 -3
- package/node_modules/jose/dist/webapi/jwks/local.js +32 -73
- package/node_modules/jose/dist/webapi/jwks/remote.js +19 -28
- package/node_modules/jose/dist/webapi/jws/compact/sign.js +5 -2
- package/node_modules/jose/dist/webapi/jws/compact/verify.js +4 -16
- package/node_modules/jose/dist/webapi/jws/flattened/sign.js +7 -65
- package/node_modules/jose/dist/webapi/jws/flattened/verify.js +3 -89
- package/node_modules/jose/dist/webapi/jws/general/sign.js +19 -15
- package/node_modules/jose/dist/webapi/jws/general/verify.js +29 -9
- package/node_modules/jose/dist/webapi/jwt/decrypt.js +5 -5
- package/node_modules/jose/dist/webapi/jwt/sign.js +2 -3
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +4 -3
- package/node_modules/jose/dist/webapi/jwt/verify.js +6 -6
- package/node_modules/jose/dist/webapi/key/export.js +37 -4
- package/node_modules/jose/dist/webapi/key/generate_key_pair.js +33 -82
- package/node_modules/jose/dist/webapi/key/generate_secret.js +2 -2
- package/node_modules/jose/dist/webapi/key/import.js +8 -8
- package/node_modules/jose/dist/webapi/lib/asn1.js +53 -122
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +1 -0
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +34 -109
- package/node_modules/jose/dist/webapi/lib/crypto_key.js +18 -126
- package/node_modules/jose/dist/webapi/lib/helpers.js +23 -0
- package/node_modules/jose/dist/webapi/lib/invalid_key_input.js +0 -1
- package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +107 -0
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +186 -0
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +114 -0
- package/node_modules/jose/dist/webapi/lib/jwk_to_key.js +8 -98
- package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +73 -0
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +74 -0
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +107 -0
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +68 -109
- package/node_modules/jose/dist/webapi/lib/key.js +132 -0
- package/node_modules/jose/dist/webapi/lib/key_algorithm.js +10 -0
- package/node_modules/jose/dist/webapi/lib/key_descriptor.js +7 -0
- package/node_modules/jose/dist/webapi/lib/key_management.js +162 -92
- package/node_modules/jose/dist/webapi/lib/options.js +48 -0
- package/node_modules/jose/dist/webapi/lib/signing.js +14 -56
- package/node_modules/jose/dist/webapi/lib/type_checks.js +13 -18
- package/node_modules/jose/dist/webapi/util/base64url.js +13 -4
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +2 -2
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -15
- package/node_modules/jose/dist/webapi/util/errors.js +1 -1
- package/node_modules/jose/package.json +2 -4
- package/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/package.json +5 -3
- package/node_modules/jose/dist/webapi/lib/aesgcmkw.js +0 -15
- package/node_modules/jose/dist/webapi/lib/aeskw.js +0 -25
- package/node_modules/jose/dist/webapi/lib/check_key_type.js +0 -122
- package/node_modules/jose/dist/webapi/lib/ecdhes.js +0 -52
- package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +0 -34
- package/node_modules/jose/dist/webapi/lib/normalize_key.js +0 -166
- package/node_modules/jose/dist/webapi/lib/pbes2kw.js +0 -42
- package/node_modules/jose/dist/webapi/lib/rsaes.js +0 -24
- package/node_modules/jose/dist/webapi/lib/validate_algorithms.js +0 -10
- package/node_modules/jose/dist/webapi/lib/validate_crit.js +0 -33
|
@@ -34,7 +34,7 @@ function compareKey(a, b) {
|
|
|
34
34
|
return 1;
|
|
35
35
|
}
|
|
36
36
|
if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
|
|
37
|
-
return 1;
|
|
37
|
+
return b === TAIL_WILDCARD_REG_EXP_STR ? -1 : 1;
|
|
38
38
|
} else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
|
|
39
39
|
return -1;
|
|
40
40
|
}
|
|
@@ -46,76 +46,75 @@ function compareKey(a, b) {
|
|
|
46
46
|
return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
|
|
47
47
|
}
|
|
48
48
|
class Node {
|
|
49
|
+
// handler index of a dynamic path, or -1 for a static path terminal
|
|
49
50
|
#index;
|
|
50
51
|
#varIndex;
|
|
51
52
|
#children = /* @__PURE__ */ Object.create(null);
|
|
52
|
-
insert(tokens, index, paramMap, context,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
74
|
-
if (/\((?!\?:)/.test(regexpStr)) {
|
|
75
|
-
throw PATH_ERROR;
|
|
53
|
+
insert(tokens, index, paramMap, context, isStatic) {
|
|
54
|
+
let node = this;
|
|
55
|
+
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
56
|
+
const token = tokens[i];
|
|
57
|
+
const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : null : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
58
|
+
let nextNode;
|
|
59
|
+
if (pattern) {
|
|
60
|
+
const name = pattern[1];
|
|
61
|
+
let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
|
|
62
|
+
if (name && pattern[2]) {
|
|
63
|
+
if (regexpStr === ".*") {
|
|
64
|
+
throw PATH_ERROR;
|
|
65
|
+
}
|
|
66
|
+
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
67
|
+
if (/\((?!\?:)/.test(regexpStr)) {
|
|
68
|
+
throw PATH_ERROR;
|
|
69
|
+
}
|
|
70
|
+
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) {
|
|
71
|
+
throw PATH_ERROR;
|
|
72
|
+
}
|
|
76
73
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
nextNode = node.#children[regexpStr];
|
|
75
|
+
if (!nextNode) {
|
|
76
|
+
if (regexpStr !== ONLY_WILDCARD_REG_EXP_STR && regexpStr !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
77
|
+
for (const k in node.#children) {
|
|
78
|
+
if (
|
|
79
|
+
// a single-char pattern coexists with single-char literals as a literal does
|
|
80
|
+
(regexpStr.length > 1 || k.length > 1) && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
|
|
81
|
+
) {
|
|
82
|
+
throw PATH_ERROR;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
nextNode = node.#children[regexpStr] = new Node();
|
|
84
87
|
}
|
|
85
|
-
if (pathErrorCheckOnly) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
node = this.#children[regexpStr] = new Node();
|
|
89
88
|
if (name !== "") {
|
|
90
|
-
|
|
89
|
+
nextNode.#varIndex ??= context.varIndex++;
|
|
90
|
+
paramMap.push([name, nextNode.#varIndex]);
|
|
91
91
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)) {
|
|
102
|
-
throw PATH_ERROR;
|
|
92
|
+
} else {
|
|
93
|
+
nextNode = node.#children[token];
|
|
94
|
+
if (!nextNode) {
|
|
95
|
+
for (const k in node.#children) {
|
|
96
|
+
if (k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
97
|
+
throw PATH_ERROR;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
nextNode = node.#children[token] = new Node();
|
|
103
101
|
}
|
|
104
|
-
if (pathErrorCheckOnly) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
node = this.#children[token] = new Node();
|
|
108
102
|
}
|
|
103
|
+
node = nextNode;
|
|
104
|
+
}
|
|
105
|
+
if (node.#index !== void 0) {
|
|
106
|
+
throw PATH_ERROR;
|
|
109
107
|
}
|
|
110
|
-
node
|
|
108
|
+
node.#index = isStatic ? -1 : index;
|
|
111
109
|
}
|
|
112
110
|
buildRegExpStr() {
|
|
113
111
|
const childKeys = Object.keys(this.#children).sort(compareKey);
|
|
114
112
|
const strList = childKeys.map((k) => {
|
|
115
113
|
const c = this.#children[k];
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
const childStr = c.buildRegExpStr();
|
|
115
|
+
return childStr === "" ? "" : (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
|
|
116
|
+
}).filter(Boolean);
|
|
117
|
+
if (typeof this.#index === "number" && this.#index !== -1) {
|
|
119
118
|
strList.unshift(`#${this.#index}`);
|
|
120
119
|
}
|
|
121
120
|
if (strList.length === 0) {
|
|
@@ -25,7 +25,6 @@ var import_url = require("../../utils/url");
|
|
|
25
25
|
var import_matcher = require("./matcher");
|
|
26
26
|
var import_node = require("./node");
|
|
27
27
|
var import_trie = require("./trie");
|
|
28
|
-
const nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
29
28
|
let wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
30
29
|
function buildWildcardRegExp(path) {
|
|
31
30
|
return wildcardRegExpCache[path] ??= new RegExp(
|
|
@@ -38,63 +37,6 @@ function buildWildcardRegExp(path) {
|
|
|
38
37
|
function clearWildcardRegExpCache() {
|
|
39
38
|
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
40
39
|
}
|
|
41
|
-
function buildMatcherFromPreprocessedRoutes(routes) {
|
|
42
|
-
const trie = new import_trie.Trie();
|
|
43
|
-
const handlerData = [];
|
|
44
|
-
if (routes.length === 0) {
|
|
45
|
-
return nullMatcher;
|
|
46
|
-
}
|
|
47
|
-
const routesWithStaticPathFlag = routes.map(
|
|
48
|
-
(route) => [!/\*|\/:/.test(route[0]), ...route]
|
|
49
|
-
).sort(
|
|
50
|
-
([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length
|
|
51
|
-
);
|
|
52
|
-
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
53
|
-
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
54
|
-
const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
|
|
55
|
-
if (pathErrorCheckOnly) {
|
|
56
|
-
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), import_matcher.emptyParam];
|
|
57
|
-
} else {
|
|
58
|
-
j++;
|
|
59
|
-
}
|
|
60
|
-
let paramAssoc;
|
|
61
|
-
try {
|
|
62
|
-
paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
throw e === import_node.PATH_ERROR ? new import_router.UnsupportedPathError(path) : e;
|
|
65
|
-
}
|
|
66
|
-
if (pathErrorCheckOnly) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
handlerData[j] = handlers.map(([h, paramCount]) => {
|
|
70
|
-
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
71
|
-
paramCount -= 1;
|
|
72
|
-
for (; paramCount >= 0; paramCount--) {
|
|
73
|
-
const [key, value] = paramAssoc[paramCount];
|
|
74
|
-
paramIndexMap[key] = value;
|
|
75
|
-
}
|
|
76
|
-
return [h, paramIndexMap];
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
80
|
-
for (let i = 0, len = handlerData.length; i < len; i++) {
|
|
81
|
-
for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
|
|
82
|
-
const map = handlerData[i][j]?.[1];
|
|
83
|
-
if (!map) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const keys = Object.keys(map);
|
|
87
|
-
for (let k = 0, len3 = keys.length; k < len3; k++) {
|
|
88
|
-
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const handlerMap = [];
|
|
93
|
-
for (const i in indexReplacementMap) {
|
|
94
|
-
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
95
|
-
}
|
|
96
|
-
return [regexp, handlerMap, staticMap];
|
|
97
|
-
}
|
|
98
40
|
function findMiddleware(middleware, path) {
|
|
99
41
|
if (!middleware) {
|
|
100
42
|
return void 0;
|
|
@@ -110,9 +52,18 @@ class RegExpRouter {
|
|
|
110
52
|
name = "RegExpRouter";
|
|
111
53
|
#middleware;
|
|
112
54
|
#routes;
|
|
55
|
+
#tries;
|
|
113
56
|
constructor() {
|
|
114
57
|
this.#middleware = { [import_router.METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
115
58
|
this.#routes = { [import_router.METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
59
|
+
this.#tries = { [import_router.METHOD_NAME_ALL]: new import_trie.Trie() };
|
|
60
|
+
}
|
|
61
|
+
#insertPath(method, path) {
|
|
62
|
+
try {
|
|
63
|
+
this.#tries[method].insert(path, !/\*|\/:/.test(path));
|
|
64
|
+
} catch (e) {
|
|
65
|
+
throw e === import_node.PATH_ERROR ? new import_router.UnsupportedPathError(path) : e;
|
|
66
|
+
}
|
|
116
67
|
}
|
|
117
68
|
add(method, path, handler) {
|
|
118
69
|
const middleware = this.#middleware;
|
|
@@ -121,11 +72,12 @@ class RegExpRouter {
|
|
|
121
72
|
throw new Error(import_router.MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
122
73
|
}
|
|
123
74
|
if (!middleware[method]) {
|
|
124
|
-
;
|
|
75
|
+
this.#tries[method] = new import_trie.Trie();
|
|
125
76
|
[middleware, routes].forEach((handlerMap) => {
|
|
126
77
|
handlerMap[method] = /* @__PURE__ */ Object.create(null);
|
|
127
78
|
Object.keys(handlerMap[import_router.METHOD_NAME_ALL]).forEach((p) => {
|
|
128
79
|
handlerMap[method][p] = [...handlerMap[import_router.METHOD_NAME_ALL][p]];
|
|
80
|
+
this.#insertPath(method, p);
|
|
129
81
|
});
|
|
130
82
|
});
|
|
131
83
|
}
|
|
@@ -135,13 +87,12 @@ class RegExpRouter {
|
|
|
135
87
|
const paramCount = (path.match(/\/:/g) || []).length;
|
|
136
88
|
if (/\*$/.test(path)) {
|
|
137
89
|
const re = buildWildcardRegExp(path);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
90
|
+
Object.keys(middleware).forEach((m) => {
|
|
91
|
+
if ((method === import_router.METHOD_NAME_ALL || method === m) && !middleware[m][path]) {
|
|
92
|
+
this.#insertPath(m, path);
|
|
93
|
+
middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware[import_router.METHOD_NAME_ALL], path) || [];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
145
96
|
Object.keys(middleware).forEach((m) => {
|
|
146
97
|
if (method === import_router.METHOD_NAME_ALL || method === m) {
|
|
147
98
|
Object.keys(middleware[m]).forEach((p) => {
|
|
@@ -163,9 +114,12 @@ class RegExpRouter {
|
|
|
163
114
|
const path2 = paths[i];
|
|
164
115
|
Object.keys(routes).forEach((m) => {
|
|
165
116
|
if (method === import_router.METHOD_NAME_ALL || method === m) {
|
|
166
|
-
routes[m][path2]
|
|
167
|
-
|
|
168
|
-
|
|
117
|
+
if (!routes[m][path2]) {
|
|
118
|
+
this.#insertPath(m, path2);
|
|
119
|
+
routes[m][path2] = [
|
|
120
|
+
...findMiddleware(middleware[m], path2) || findMiddleware(middleware[import_router.METHOD_NAME_ALL], path2) || []
|
|
121
|
+
];
|
|
122
|
+
}
|
|
169
123
|
routes[m][path2].push([handler, paramCount - len + i + 1]);
|
|
170
124
|
}
|
|
171
125
|
});
|
|
@@ -177,29 +131,54 @@ class RegExpRouter {
|
|
|
177
131
|
Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => {
|
|
178
132
|
matchers[method] ||= this.#buildMatcher(method);
|
|
179
133
|
});
|
|
180
|
-
this.#middleware = this.#routes = void 0;
|
|
134
|
+
this.#middleware = this.#routes = this.#tries = void 0;
|
|
181
135
|
clearWildcardRegExpCache();
|
|
182
136
|
return matchers;
|
|
183
137
|
}
|
|
184
138
|
#buildMatcher(method) {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
139
|
+
const middleware = this.#middleware[method];
|
|
140
|
+
const routes = this.#routes[method];
|
|
141
|
+
const trie = this.#tries[method];
|
|
142
|
+
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
143
|
+
const handlerData = [];
|
|
144
|
+
[middleware, routes].forEach((r) => {
|
|
145
|
+
for (const path in r) {
|
|
146
|
+
const handlers = r[path];
|
|
147
|
+
const pathData = trie.paths[path];
|
|
148
|
+
if (!pathData) {
|
|
149
|
+
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), import_matcher.emptyParam];
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const paramAssoc = pathData[1];
|
|
153
|
+
handlerData[pathData[0]] = handlers.map(([h, paramCount]) => {
|
|
154
|
+
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
155
|
+
paramCount -= 1;
|
|
156
|
+
for (; paramCount >= 0; paramCount--) {
|
|
157
|
+
const [key, value] = paramAssoc[paramCount];
|
|
158
|
+
paramIndexMap[key] = value;
|
|
159
|
+
}
|
|
160
|
+
return [h, paramIndexMap];
|
|
161
|
+
});
|
|
196
162
|
}
|
|
197
163
|
});
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
164
|
+
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
165
|
+
for (let i = 0, len = handlerData.length; i < len; i++) {
|
|
166
|
+
for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
|
|
167
|
+
const map = handlerData[i][j]?.[1];
|
|
168
|
+
if (!map) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const keys = Object.keys(map);
|
|
172
|
+
for (let k = 0, len3 = keys.length; k < len3; k++) {
|
|
173
|
+
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const handlerMap = [];
|
|
178
|
+
for (const i in indexReplacementMap) {
|
|
179
|
+
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
202
180
|
}
|
|
181
|
+
return [regexp, handlerMap, staticMap];
|
|
203
182
|
}
|
|
204
183
|
}
|
|
205
184
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -24,12 +24,20 @@ var import_node = require("./node");
|
|
|
24
24
|
class Trie {
|
|
25
25
|
#context = { varIndex: 0 };
|
|
26
26
|
#root = new import_node.Node();
|
|
27
|
-
|
|
27
|
+
#index = 0;
|
|
28
|
+
// dynamic path -> [handler index, param assoc]; static paths are not registered
|
|
29
|
+
paths = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
insert(path, isStatic) {
|
|
31
|
+
if (isStatic) {
|
|
32
|
+
this.#root.insert(path.split(""), 0, [], this.#context, true);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
28
35
|
const paramAssoc = [];
|
|
29
36
|
const groups = [];
|
|
37
|
+
let markedPath = path;
|
|
30
38
|
for (let i = 0; ; ) {
|
|
31
39
|
let replaced = false;
|
|
32
|
-
|
|
40
|
+
markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
|
|
33
41
|
const mark = `@\\${i}`;
|
|
34
42
|
groups[i] = [mark, m];
|
|
35
43
|
i++;
|
|
@@ -40,7 +48,7 @@ class Trie {
|
|
|
40
48
|
break;
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
|
-
const tokens =
|
|
51
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
44
52
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
45
53
|
const [mark] = groups[i];
|
|
46
54
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -50,8 +58,8 @@ class Trie {
|
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
|
-
this.#root.insert(tokens, index, paramAssoc, this.#context,
|
|
54
|
-
|
|
61
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
|
|
62
|
+
this.paths[path] = [this.#index++, paramAssoc];
|
|
55
63
|
}
|
|
56
64
|
buildRegExp() {
|
|
57
65
|
let regexp = this.#root.buildRegExpStr();
|
|
@@ -23,76 +23,51 @@ module.exports = __toCommonJS(node_exports);
|
|
|
23
23
|
var import_router = require("../../router");
|
|
24
24
|
var import_url = require("../../utils/url");
|
|
25
25
|
const emptyParams = /* @__PURE__ */ Object.create(null);
|
|
26
|
-
|
|
27
|
-
for (const _ in children) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
26
|
+
let order = 0;
|
|
32
27
|
class Node {
|
|
33
|
-
#methods;
|
|
34
|
-
#children;
|
|
35
|
-
#patterns;
|
|
36
|
-
#
|
|
28
|
+
#methods = [];
|
|
29
|
+
#children = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
#patterns = [];
|
|
31
|
+
#pattern;
|
|
37
32
|
#params = emptyParams;
|
|
38
|
-
constructor(method, handler, children) {
|
|
39
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
40
|
-
this.#methods = [];
|
|
41
|
-
if (method && handler) {
|
|
42
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
43
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
44
|
-
this.#methods = [m];
|
|
45
|
-
}
|
|
46
|
-
this.#patterns = [];
|
|
47
|
-
}
|
|
48
33
|
insert(method, path, handler) {
|
|
49
|
-
this.#order = ++this.#order;
|
|
50
34
|
let curNode = this;
|
|
51
35
|
const parts = (0, import_url.splitRoutingPath)(path);
|
|
52
|
-
const possibleKeys =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const nextP = parts[i
|
|
56
|
-
const pattern = (0, import_url.getPattern)(p, nextP);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
continue;
|
|
36
|
+
const possibleKeys = /* @__PURE__ */ new Set();
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (const p of parts) {
|
|
39
|
+
const nextP = parts[++i];
|
|
40
|
+
const pattern = (0, import_url.getPattern)(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
41
|
+
const isParam = Array.isArray(pattern);
|
|
42
|
+
const key = isParam ? pattern[0] : pattern || p;
|
|
43
|
+
const child = curNode.#children[key] ||= new Node();
|
|
44
|
+
if (pattern && !child.#pattern) {
|
|
45
|
+
child.#pattern = pattern;
|
|
46
|
+
curNode.#patterns.push(child);
|
|
64
47
|
}
|
|
65
|
-
curNode
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
possibleKeys.push(pattern[1]);
|
|
48
|
+
curNode = child;
|
|
49
|
+
if (isParam) {
|
|
50
|
+
possibleKeys.add(pattern[1]);
|
|
69
51
|
}
|
|
70
|
-
curNode = curNode.#children[key];
|
|
71
52
|
}
|
|
72
53
|
curNode.#methods.push({
|
|
73
54
|
[method]: {
|
|
74
55
|
handler,
|
|
75
|
-
possibleKeys: possibleKeys
|
|
76
|
-
score:
|
|
56
|
+
possibleKeys: [...possibleKeys],
|
|
57
|
+
score: ++order
|
|
77
58
|
}
|
|
78
59
|
});
|
|
79
|
-
return curNode;
|
|
80
60
|
}
|
|
81
61
|
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
82
62
|
for (let i = 0, len = node.#methods.length; i < len; i++) {
|
|
83
63
|
const m = node.#methods[i];
|
|
84
64
|
const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
|
|
85
|
-
|
|
86
|
-
if (handlerSet !== void 0) {
|
|
65
|
+
if (handlerSet) {
|
|
87
66
|
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
88
67
|
handlerSets.push(handlerSet);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const processed = processedSet[handlerSet.score];
|
|
93
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
94
|
-
processedSet[handlerSet.score] = true;
|
|
95
|
-
}
|
|
68
|
+
for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
|
|
69
|
+
const key = handlerSet.possibleKeys[i2];
|
|
70
|
+
handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
96
71
|
}
|
|
97
72
|
}
|
|
98
73
|
}
|
|
@@ -124,33 +99,33 @@ class Node {
|
|
|
124
99
|
tempNodes.push(nextNode);
|
|
125
100
|
}
|
|
126
101
|
}
|
|
127
|
-
for (
|
|
128
|
-
const pattern =
|
|
102
|
+
for (const child of node.#patterns) {
|
|
103
|
+
const pattern = child.#pattern;
|
|
129
104
|
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
130
|
-
if (pattern === "
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
if (typeof pattern === "string") {
|
|
106
|
+
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
107
|
+
this.#pushHandlerSets(handlerSets, child, method, node.#params);
|
|
108
|
+
if (pattern === "*") {
|
|
109
|
+
child.#params = params;
|
|
110
|
+
tempNodes.push(child);
|
|
111
|
+
}
|
|
136
112
|
}
|
|
137
113
|
continue;
|
|
138
114
|
}
|
|
139
|
-
const [
|
|
140
|
-
if (!part &&
|
|
115
|
+
const [, name, matcher] = pattern;
|
|
116
|
+
if (!part && matcher === true) {
|
|
141
117
|
continue;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
partOffsets = new Array(len);
|
|
119
|
+
if (matcher !== true) {
|
|
120
|
+
if (!partOffsets) {
|
|
121
|
+
partOffsets = [];
|
|
147
122
|
let offset = path[0] === "/" ? 1 : 0;
|
|
148
123
|
for (let p = 0; p < len; p++) {
|
|
149
124
|
partOffsets[p] = offset;
|
|
150
125
|
offset += parts[p].length + 1;
|
|
151
126
|
}
|
|
152
127
|
}
|
|
153
|
-
const restPathString = path.
|
|
128
|
+
const restPathString = path.slice(partOffsets[i]);
|
|
154
129
|
const m = matcher.exec(restPathString);
|
|
155
130
|
if (m) {
|
|
156
131
|
params[name] = m[0];
|
|
@@ -164,11 +139,12 @@ class Node {
|
|
|
164
139
|
params
|
|
165
140
|
);
|
|
166
141
|
}
|
|
167
|
-
|
|
142
|
+
for (const _ in child.#children) {
|
|
168
143
|
child.#params = params;
|
|
169
|
-
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
144
|
+
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
170
145
|
const targetCurNodes = curNodesQueue[componentCount] ||= [];
|
|
171
146
|
targetCurNodes.push(child);
|
|
147
|
+
break;
|
|
172
148
|
}
|
|
173
149
|
continue;
|
|
174
150
|
}
|
|
@@ -196,7 +172,7 @@ class Node {
|
|
|
196
172
|
const shifted = curNodesQueue.shift();
|
|
197
173
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
198
174
|
}
|
|
199
|
-
if (handlerSets
|
|
175
|
+
if (handlerSets[1]) {
|
|
200
176
|
handlerSets.sort((a, b) => {
|
|
201
177
|
return a.score - b.score;
|
|
202
178
|
});
|
|
@@ -24,19 +24,11 @@ var import_url = require("../../utils/url");
|
|
|
24
24
|
var import_node = require("./node");
|
|
25
25
|
class TrieRouter {
|
|
26
26
|
name = "TrieRouter";
|
|
27
|
-
#node;
|
|
28
|
-
constructor() {
|
|
29
|
-
this.#node = new import_node.Node();
|
|
30
|
-
}
|
|
27
|
+
#node = new import_node.Node();
|
|
31
28
|
add(method, path, handler) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
for (let i = 0, len = results.length; i < len; i++) {
|
|
35
|
-
this.#node.insert(method, results[i], handler);
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
29
|
+
for (const result of (0, import_url.checkOptionalParameter)(path) || [path]) {
|
|
30
|
+
this.#node.insert(method, result, handler);
|
|
38
31
|
}
|
|
39
|
-
this.#node.insert(method, path, handler);
|
|
40
32
|
}
|
|
41
33
|
match(method, path) {
|
|
42
34
|
return this.#node.search(method, path);
|
|
@@ -26,7 +26,7 @@ __export(router_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(router_exports);
|
|
27
27
|
const METHOD_NAME_ALL = "ALL";
|
|
28
28
|
const METHOD_NAME_ALL_LOWERCASE = "all";
|
|
29
|
-
const METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
29
|
+
const METHODS = ["get", "post", "put", "delete", "options", "patch", "query"];
|
|
30
30
|
const MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
31
31
|
class UnsupportedPathError extends Error {
|
|
32
32
|
}
|
|
@@ -47,6 +47,7 @@ const verifySignature = async (base64Signature, value, secret) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
50
|
+
const relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/;
|
|
50
51
|
const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
51
52
|
const trimCookieWhitespace = (value) => {
|
|
52
53
|
let start = 0;
|
|
@@ -79,7 +80,7 @@ const parse = (cookie, name) => {
|
|
|
79
80
|
continue;
|
|
80
81
|
}
|
|
81
82
|
const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
|
|
82
|
-
if (name && name !== cookieName || !
|
|
83
|
+
if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) {
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
|
|
@@ -87,7 +88,7 @@ const parse = (cookie, name) => {
|
|
|
87
88
|
cookieValue = cookieValue.slice(1, -1);
|
|
88
89
|
}
|
|
89
90
|
if (validCookieValueRegEx.test(cookieValue)) {
|
|
90
|
-
parsedCookie[cookieName] =
|
|
91
|
+
parsedCookie[cookieName] = (0, import_url.tryDecodeURIComponent)(cookieValue);
|
|
91
92
|
if (name) {
|
|
92
93
|
break;
|
|
93
94
|
}
|
|
@@ -30,12 +30,14 @@ __export(ipaddr_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(ipaddr_exports);
|
|
31
31
|
const expandIPv6 = (ipV6) => {
|
|
32
32
|
const sections = ipV6.split(":");
|
|
33
|
-
|
|
33
|
+
const lastSection = sections.at(-1);
|
|
34
|
+
if (IPV4_REGEX.test(lastSection)) {
|
|
35
|
+
const octets = lastSection.split(".").map(Number);
|
|
34
36
|
sections.splice(
|
|
35
37
|
-1,
|
|
36
38
|
1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
(octets[0] << 8 | octets[1]).toString(16),
|
|
40
|
+
(octets[2] << 8 | octets[3]).toString(16)
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
for (let i = 0; i < sections.length; i++) {
|
|
@@ -80,8 +80,11 @@ class StreamingApi {
|
|
|
80
80
|
}
|
|
81
81
|
async pipe(body) {
|
|
82
82
|
this.writer.releaseLock();
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
try {
|
|
84
|
+
await body.pipeTo(this.writable, { preventClose: true, preventAbort: true });
|
|
85
|
+
} finally {
|
|
86
|
+
this.writer = this.writable.getWriter();
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
onAbort(listener) {
|
|
87
90
|
this.abortSubscribers.push(listener);
|