hono 4.12.0 → 4.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.
@@ -9,7 +9,8 @@ var getConnInfo = (c) => {
9
9
  } else {
10
10
  const xff = c.req.header("x-forwarded-for");
11
11
  if (xff) {
12
- address = xff.split(",")[0].trim();
12
+ const ips = xff.split(",");
13
+ address = ips[ips.length - 1].trim();
13
14
  }
14
15
  }
15
16
  return {
@@ -31,7 +31,8 @@ const getConnInfo = (c) => {
31
31
  } else {
32
32
  const xff = c.req.header("x-forwarded-for");
33
33
  if (xff) {
34
- address = xff.split(",")[0].trim();
34
+ const ips = xff.split(",");
35
+ address = ips[ips.length - 1].trim();
35
36
  }
36
37
  }
37
38
  return {
@@ -345,9 +345,6 @@ class Context {
345
345
  * ```
346
346
  */
347
347
  body = (data, arg, headers) => this.#newResponse(data, arg, headers);
348
- #useFastPath() {
349
- return !this.#preparedHeaders && !this.#status && !this.finalized;
350
- }
351
348
  /**
352
349
  * `.text()` can render text as `Content-Type:text/plain`.
353
350
  *
@@ -361,7 +358,7 @@ class Context {
361
358
  * ```
362
359
  */
363
360
  text = (text, arg, headers) => {
364
- return this.#useFastPath() && !arg && !headers ? createResponseInstance(text) : this.#newResponse(
361
+ return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(
365
362
  text,
366
363
  arg,
367
364
  setDefaultContentType(TEXT_PLAIN, headers)
@@ -380,7 +377,7 @@ class Context {
380
377
  * ```
381
378
  */
382
379
  json = (object, arg, headers) => {
383
- return this.#useFastPath() && !arg && !headers ? Response.json(object) : this.#newResponse(
380
+ return this.#newResponse(
384
381
  JSON.stringify(object),
385
382
  arg,
386
383
  setDefaultContentType("application/json", headers)
package/dist/context.js CHANGED
@@ -322,9 +322,6 @@ var Context = class {
322
322
  * ```
323
323
  */
324
324
  body = (data, arg, headers) => this.#newResponse(data, arg, headers);
325
- #useFastPath() {
326
- return !this.#preparedHeaders && !this.#status && !this.finalized;
327
- }
328
325
  /**
329
326
  * `.text()` can render text as `Content-Type:text/plain`.
330
327
  *
@@ -338,7 +335,7 @@ var Context = class {
338
335
  * ```
339
336
  */
340
337
  text = (text, arg, headers) => {
341
- return this.#useFastPath() && !arg && !headers ? createResponseInstance(text) : this.#newResponse(
338
+ return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(
342
339
  text,
343
340
  arg,
344
341
  setDefaultContentType(TEXT_PLAIN, headers)
@@ -357,7 +354,7 @@ var Context = class {
357
354
  * ```
358
355
  */
359
356
  json = (object, arg, headers) => {
360
- return this.#useFastPath() && !arg && !headers ? Response.json(object) : this.#newResponse(
357
+ return this.#newResponse(
361
358
  JSON.stringify(object),
362
359
  arg,
363
360
  setDefaultContentType("application/json", headers)
@@ -4,4 +4,4 @@
4
4
  */
5
5
  export { hc } from './client';
6
6
  export { parseResponse, DetailedError } from './utils';
7
- export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions, ClientRequest, ClientResponse, } from './types';
7
+ export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions, ClientRequest, ClientResponse, ApplyGlobalResponse, } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.12.0",
3
+ "version": "4.12.2",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",