hono 4.8.7 → 4.8.9
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 +0 -7
- package/dist/cjs/context.js +5 -2
- package/dist/cjs/utils/url.js +0 -12
- package/dist/context.js +5 -2
- package/dist/types/utils/url.d.ts +0 -6
- package/dist/utils/url.js +0 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,13 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
<hr />
|
|
8
8
|
|
|
9
|
-
<p align="center">
|
|
10
|
-
<a href="https://hono.dev"><b>Documentation 👉 hono.dev</b></a><br />
|
|
11
|
-
<i>Now supports <a href="https://jsr.io/@hono/hono">JSR</a> and <code>deno.land/x</code> is deprecated! See <a href="docs/MIGRATION.md">Migration guide</a>.</i>
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
<hr />
|
|
15
|
-
|
|
16
9
|
[](https://github.com/honojs/hono/actions)
|
|
17
10
|
[](https://github.com/honojs/hono/blob/main/LICENSE)
|
|
18
11
|
[](https://www.npmjs.com/package/hono)
|
package/dist/cjs/context.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(context_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(context_exports);
|
|
25
25
|
var import_request = require("./request");
|
|
26
26
|
var import_html = require("./utils/html");
|
|
27
|
-
var import_url = require("./utils/url");
|
|
28
27
|
const TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
29
28
|
const setDefaultContentType = (contentType, headers) => {
|
|
30
29
|
return {
|
|
@@ -188,7 +187,11 @@ class Context {
|
|
|
188
187
|
return typeof html === "object" ? (0, import_html.resolveCallback)(html, import_html.HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
|
|
189
188
|
};
|
|
190
189
|
redirect = (location, status) => {
|
|
191
|
-
|
|
190
|
+
const locationString = String(location);
|
|
191
|
+
this.header(
|
|
192
|
+
"Location",
|
|
193
|
+
!/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
|
|
194
|
+
);
|
|
192
195
|
return this.newResponse(null, status ?? 302);
|
|
193
196
|
};
|
|
194
197
|
notFound = () => {
|
package/dist/cjs/utils/url.js
CHANGED
|
@@ -27,7 +27,6 @@ __export(url_exports, {
|
|
|
27
27
|
getQueryParams: () => getQueryParams,
|
|
28
28
|
getQueryStrings: () => getQueryStrings,
|
|
29
29
|
mergePath: () => mergePath,
|
|
30
|
-
safeEncodeURI: () => safeEncodeURI,
|
|
31
30
|
splitPath: () => splitPath,
|
|
32
31
|
splitRoutingPath: () => splitRoutingPath,
|
|
33
32
|
tryDecode: () => tryDecode
|
|
@@ -237,16 +236,6 @@ const getQueryParams = (url, key) => {
|
|
|
237
236
|
return _getQueryParam(url, key, true);
|
|
238
237
|
};
|
|
239
238
|
const decodeURIComponent_ = decodeURIComponent;
|
|
240
|
-
const safeEncodeURI = (str) => {
|
|
241
|
-
try {
|
|
242
|
-
return encodeURI(decodeURI(str));
|
|
243
|
-
} catch (e) {
|
|
244
|
-
if (e instanceof URIError) {
|
|
245
|
-
return encodeURI(str);
|
|
246
|
-
}
|
|
247
|
-
throw e;
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
239
|
// Annotate the CommonJS export names for ESM import in node:
|
|
251
240
|
0 && (module.exports = {
|
|
252
241
|
checkOptionalParameter,
|
|
@@ -258,7 +247,6 @@ const safeEncodeURI = (str) => {
|
|
|
258
247
|
getQueryParams,
|
|
259
248
|
getQueryStrings,
|
|
260
249
|
mergePath,
|
|
261
|
-
safeEncodeURI,
|
|
262
250
|
splitPath,
|
|
263
251
|
splitRoutingPath,
|
|
264
252
|
tryDecode
|
package/dist/context.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/context.ts
|
|
2
2
|
import { HonoRequest } from "./request.js";
|
|
3
3
|
import { HtmlEscapedCallbackPhase, resolveCallback } from "./utils/html.js";
|
|
4
|
-
import { safeEncodeURI } from "./utils/url.js";
|
|
5
4
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
6
5
|
var setDefaultContentType = (contentType, headers) => {
|
|
7
6
|
return {
|
|
@@ -165,7 +164,11 @@ var Context = class {
|
|
|
165
164
|
return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
|
|
166
165
|
};
|
|
167
166
|
redirect = (location, status) => {
|
|
168
|
-
|
|
167
|
+
const locationString = String(location);
|
|
168
|
+
this.header(
|
|
169
|
+
"Location",
|
|
170
|
+
!/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
|
|
171
|
+
);
|
|
169
172
|
return this.newResponse(null, status ?? 302);
|
|
170
173
|
};
|
|
171
174
|
notFound = () => {
|
|
@@ -30,10 +30,4 @@ export declare const checkOptionalParameter: (path: string) => string[] | null;
|
|
|
30
30
|
export declare const getQueryParam: (url: string, key?: string) => string | undefined | Record<string, string>;
|
|
31
31
|
export declare const getQueryParams: (url: string, key?: string) => string[] | undefined | Record<string, string[]>;
|
|
32
32
|
export declare const decodeURIComponent_: typeof decodeURIComponent;
|
|
33
|
-
/**
|
|
34
|
-
* This function ensures that the string is safely encoded,
|
|
35
|
-
* and not double-encoded.
|
|
36
|
-
* The input string may or may not escaped by encodeURI.
|
|
37
|
-
*/
|
|
38
|
-
export declare const safeEncodeURI: (str: string) => string;
|
|
39
33
|
export {};
|
package/dist/utils/url.js
CHANGED
|
@@ -203,16 +203,6 @@ var getQueryParams = (url, key) => {
|
|
|
203
203
|
return _getQueryParam(url, key, true);
|
|
204
204
|
};
|
|
205
205
|
var decodeURIComponent_ = decodeURIComponent;
|
|
206
|
-
var safeEncodeURI = (str) => {
|
|
207
|
-
try {
|
|
208
|
-
return encodeURI(decodeURI(str));
|
|
209
|
-
} catch (e) {
|
|
210
|
-
if (e instanceof URIError) {
|
|
211
|
-
return encodeURI(str);
|
|
212
|
-
}
|
|
213
|
-
throw e;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
206
|
export {
|
|
217
207
|
checkOptionalParameter,
|
|
218
208
|
decodeURIComponent_,
|
|
@@ -223,7 +213,6 @@ export {
|
|
|
223
213
|
getQueryParams,
|
|
224
214
|
getQueryStrings,
|
|
225
215
|
mergePath,
|
|
226
|
-
safeEncodeURI,
|
|
227
216
|
splitPath,
|
|
228
217
|
splitRoutingPath,
|
|
229
218
|
tryDecode
|