hono 3.12.1 → 3.12.2
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/dist/adapter/netlify/index.js +2 -0
- package/dist/cjs/adapter/netlify/index.js +18 -0
- package/dist/cjs/client/client.js +1 -1
- package/dist/cjs/middleware/cache/index.js +13 -4
- package/dist/cjs/utils/url.js +23 -5
- package/dist/client/client.js +1 -1
- package/dist/middleware/cache/index.js +13 -4
- package/dist/types/adapter/netlify/handler.d.ts +1 -1
- package/dist/types/adapter/netlify/index.d.ts +1 -0
- package/dist/utils/url.js +23 -5
- package/package.json +6 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var netlify_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(netlify_exports);
|
|
18
|
+
__reExport(netlify_exports, require("./mod"), module.exports);
|
|
@@ -25,9 +25,18 @@ const cache = (options) => {
|
|
|
25
25
|
if (options.wait === void 0) {
|
|
26
26
|
options.wait = false;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const directives = options.cacheControl?.split(",").map((directive) => directive.toLowerCase());
|
|
29
|
+
const addHeader = (c) => {
|
|
30
|
+
if (directives) {
|
|
31
|
+
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
|
|
32
|
+
for (const directive of directives) {
|
|
33
|
+
let [name, value] = directive.trim().split("=", 2);
|
|
34
|
+
name = name.toLowerCase();
|
|
35
|
+
if (!existingDirectives.includes(name)) {
|
|
36
|
+
c.header("Cache-Control", `${name}${value ? `=${value}` : ""}`, { append: true });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
31
40
|
};
|
|
32
41
|
return async function cache2(c, next) {
|
|
33
42
|
const key = c.req.url;
|
|
@@ -38,7 +47,7 @@ const cache = (options) => {
|
|
|
38
47
|
if (!c.res.ok) {
|
|
39
48
|
return;
|
|
40
49
|
}
|
|
41
|
-
addHeader(c
|
|
50
|
+
addHeader(c);
|
|
42
51
|
const response2 = c.res.clone();
|
|
43
52
|
if (options.wait) {
|
|
44
53
|
await cache3.put(key, response2);
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -121,12 +121,30 @@ const mergePath = (...paths) => {
|
|
|
121
121
|
return p;
|
|
122
122
|
};
|
|
123
123
|
const checkOptionalParameter = (path) => {
|
|
124
|
-
|
|
125
|
-
if (!match)
|
|
124
|
+
if (!path.match(/\:.+\?$/))
|
|
126
125
|
return null;
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
126
|
+
const segments = path.split("/");
|
|
127
|
+
const results = [];
|
|
128
|
+
let basePath = "";
|
|
129
|
+
segments.forEach((segment) => {
|
|
130
|
+
if (segment !== "" && !/\:/.test(segment)) {
|
|
131
|
+
basePath += "/" + segment;
|
|
132
|
+
} else if (/\:/.test(segment)) {
|
|
133
|
+
if (/\?/.test(segment)) {
|
|
134
|
+
if (results.length === 0 && basePath === "") {
|
|
135
|
+
results.push("/");
|
|
136
|
+
} else {
|
|
137
|
+
results.push(basePath);
|
|
138
|
+
}
|
|
139
|
+
const optionalSegment = segment.replace("?", "");
|
|
140
|
+
basePath += "/" + optionalSegment;
|
|
141
|
+
results.push(basePath);
|
|
142
|
+
} else {
|
|
143
|
+
basePath += "/" + segment;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
130
148
|
};
|
|
131
149
|
const _decodeURI = (value) => {
|
|
132
150
|
if (!/[%+]/.test(value)) {
|
package/dist/client/client.js
CHANGED
|
@@ -3,9 +3,18 @@ var cache = (options) => {
|
|
|
3
3
|
if (options.wait === void 0) {
|
|
4
4
|
options.wait = false;
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const directives = options.cacheControl?.split(",").map((directive) => directive.toLowerCase());
|
|
7
|
+
const addHeader = (c) => {
|
|
8
|
+
if (directives) {
|
|
9
|
+
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
|
|
10
|
+
for (const directive of directives) {
|
|
11
|
+
let [name, value] = directive.trim().split("=", 2);
|
|
12
|
+
name = name.toLowerCase();
|
|
13
|
+
if (!existingDirectives.includes(name)) {
|
|
14
|
+
c.header("Cache-Control", `${name}${value ? `=${value}` : ""}`, { append: true });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
9
18
|
};
|
|
10
19
|
return async function cache2(c, next) {
|
|
11
20
|
const key = c.req.url;
|
|
@@ -16,7 +25,7 @@ var cache = (options) => {
|
|
|
16
25
|
if (!c.res.ok) {
|
|
17
26
|
return;
|
|
18
27
|
}
|
|
19
|
-
addHeader(c
|
|
28
|
+
addHeader(c);
|
|
20
29
|
const response2 = c.res.clone();
|
|
21
30
|
if (options.wait) {
|
|
22
31
|
await cache3.put(key, response2);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mod';
|
package/dist/utils/url.js
CHANGED
|
@@ -89,12 +89,30 @@ var mergePath = (...paths) => {
|
|
|
89
89
|
return p;
|
|
90
90
|
};
|
|
91
91
|
var checkOptionalParameter = (path) => {
|
|
92
|
-
|
|
93
|
-
if (!match)
|
|
92
|
+
if (!path.match(/\:.+\?$/))
|
|
94
93
|
return null;
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
94
|
+
const segments = path.split("/");
|
|
95
|
+
const results = [];
|
|
96
|
+
let basePath = "";
|
|
97
|
+
segments.forEach((segment) => {
|
|
98
|
+
if (segment !== "" && !/\:/.test(segment)) {
|
|
99
|
+
basePath += "/" + segment;
|
|
100
|
+
} else if (/\:/.test(segment)) {
|
|
101
|
+
if (/\?/.test(segment)) {
|
|
102
|
+
if (results.length === 0 && basePath === "") {
|
|
103
|
+
results.push("/");
|
|
104
|
+
} else {
|
|
105
|
+
results.push(basePath);
|
|
106
|
+
}
|
|
107
|
+
const optionalSegment = segment.replace("?", "");
|
|
108
|
+
basePath += "/" + optionalSegment;
|
|
109
|
+
results.push(basePath);
|
|
110
|
+
} else {
|
|
111
|
+
basePath += "/" + segment;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
98
116
|
};
|
|
99
117
|
var _decodeURI = (value) => {
|
|
100
118
|
if (!/[%+]/.test(value)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"description": "Ultrafast web framework for the Edges",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -269,6 +269,11 @@
|
|
|
269
269
|
"import": "./dist/adapter/vercel/index.js",
|
|
270
270
|
"require": "./dist/cjs/adapter/vercel/index.js"
|
|
271
271
|
},
|
|
272
|
+
"./netlify": {
|
|
273
|
+
"types": "./dist/types/adapter/netlify/index.d.ts",
|
|
274
|
+
"import": "./dist/adapter/netlify/index.js",
|
|
275
|
+
"require": "./dist/cjs/adapter/netlify/index.js"
|
|
276
|
+
},
|
|
272
277
|
"./lambda-edge": {
|
|
273
278
|
"types": "./dist/types/adapter/lambda-edge/index.d.ts",
|
|
274
279
|
"import": "./dist/adapter/lambda-edge/index.js",
|