hono 4.8.8 → 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/dist/cjs/context.js +5 -2
- package/dist/cjs/utils/url.js +0 -13
- package/dist/context.js +5 -2
- package/dist/types/utils/url.d.ts +0 -6
- package/dist/utils/url.js +0 -12
- package/package.json +1 -1
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,17 +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
|
-
const decoded = decodeURI(str);
|
|
243
|
-
return decoded === str ? encodeURI(str) : str;
|
|
244
|
-
} catch (e) {
|
|
245
|
-
if (e instanceof URIError) {
|
|
246
|
-
return encodeURI(str);
|
|
247
|
-
}
|
|
248
|
-
throw e;
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
239
|
// Annotate the CommonJS export names for ESM import in node:
|
|
252
240
|
0 && (module.exports = {
|
|
253
241
|
checkOptionalParameter,
|
|
@@ -259,7 +247,6 @@ const safeEncodeURI = (str) => {
|
|
|
259
247
|
getQueryParams,
|
|
260
248
|
getQueryStrings,
|
|
261
249
|
mergePath,
|
|
262
|
-
safeEncodeURI,
|
|
263
250
|
splitPath,
|
|
264
251
|
splitRoutingPath,
|
|
265
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,17 +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
|
-
const decoded = decodeURI(str);
|
|
209
|
-
return decoded === str ? encodeURI(str) : str;
|
|
210
|
-
} catch (e) {
|
|
211
|
-
if (e instanceof URIError) {
|
|
212
|
-
return encodeURI(str);
|
|
213
|
-
}
|
|
214
|
-
throw e;
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
206
|
export {
|
|
218
207
|
checkOptionalParameter,
|
|
219
208
|
decodeURIComponent_,
|
|
@@ -224,7 +213,6 @@ export {
|
|
|
224
213
|
getQueryParams,
|
|
225
214
|
getQueryStrings,
|
|
226
215
|
mergePath,
|
|
227
|
-
safeEncodeURI,
|
|
228
216
|
splitPath,
|
|
229
217
|
splitRoutingPath,
|
|
230
218
|
tryDecode
|