Comparing version 3.12.7 to 3.12.8
@@ -256,7 +256,5 @@ "use strict"; | ||
} | ||
if (res instanceof Response) | ||
return res; | ||
return res.then( | ||
return res instanceof Promise ? res.then( | ||
(resolved) => resolved || (c.finalized ? c.res : this.notFoundHandler(c)) | ||
).catch((err) => this.handleError(err, c)); | ||
).catch((err) => this.handleError(err, c)) : res; | ||
} | ||
@@ -263,0 +261,0 @@ const composed = (0, import_compose.compose)(matchResult[0], this.errorHandler, this.notFoundHandler); |
@@ -70,18 +70,23 @@ "use strict"; | ||
param(key) { | ||
if (key) { | ||
const param = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key]; | ||
return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0; | ||
} else { | ||
const decoded = {}; | ||
const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
const key2 = keys[i]; | ||
const value = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key2]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key2]; | ||
if (value && typeof value === "string") { | ||
decoded[key2] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value; | ||
} | ||
return key ? this.getDecodedParam(key) : this.getAllDecodedParams(); | ||
} | ||
getDecodedParam(key) { | ||
const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key]; | ||
const param = this.getParamValue(paramKey); | ||
return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0; | ||
} | ||
getAllDecodedParams() { | ||
const decoded = {}; | ||
const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]); | ||
for (const key of keys) { | ||
const value = this.getParamValue(__privateGet(this, _matchResult)[0][this.routeIndex][1][key]); | ||
if (value && typeof value === "string") { | ||
decoded[key] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value; | ||
} | ||
return decoded; | ||
} | ||
return decoded; | ||
} | ||
getParamValue(paramKey) { | ||
return __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][paramKey] : paramKey; | ||
} | ||
query(key) { | ||
@@ -88,0 +93,0 @@ return (0, import_url.getQueryParam)(this.url, key); |
@@ -234,7 +234,5 @@ var __accessCheck = (obj, member, msg) => { | ||
} | ||
if (res instanceof Response) | ||
return res; | ||
return res.then( | ||
return res instanceof Promise ? res.then( | ||
(resolved) => resolved || (c.finalized ? c.res : this.notFoundHandler(c)) | ||
).catch((err) => this.handleError(err, c)); | ||
).catch((err) => this.handleError(err, c)) : res; | ||
} | ||
@@ -241,0 +239,0 @@ const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler); |
@@ -49,18 +49,23 @@ var __accessCheck = (obj, member, msg) => { | ||
param(key) { | ||
if (key) { | ||
const param = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key]; | ||
return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0; | ||
} else { | ||
const decoded = {}; | ||
const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]); | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
const key2 = keys[i]; | ||
const value = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key2]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key2]; | ||
if (value && typeof value === "string") { | ||
decoded[key2] = /\%/.test(value) ? decodeURIComponent_(value) : value; | ||
} | ||
return key ? this.getDecodedParam(key) : this.getAllDecodedParams(); | ||
} | ||
getDecodedParam(key) { | ||
const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key]; | ||
const param = this.getParamValue(paramKey); | ||
return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0; | ||
} | ||
getAllDecodedParams() { | ||
const decoded = {}; | ||
const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]); | ||
for (const key of keys) { | ||
const value = this.getParamValue(__privateGet(this, _matchResult)[0][this.routeIndex][1][key]); | ||
if (value && typeof value === "string") { | ||
decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value; | ||
} | ||
return decoded; | ||
} | ||
return decoded; | ||
} | ||
getParamValue(paramKey) { | ||
return __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][paramKey] : paramKey; | ||
} | ||
query(key) { | ||
@@ -67,0 +72,0 @@ return getQueryParam(this.url, key); |
@@ -114,2 +114,2 @@ import type { Env, Input, MiddlewareHandler, H, HandlerResponse } from '../../types'; | ||
export declare const createFactory: <E extends Env = any, P extends string = any>() => Factory<E, P>; | ||
export declare const createMiddleware: <E extends Env = any, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler) => MiddlewareHandler<E, P, I>; | ||
export declare const createMiddleware: <E extends Env = any, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>; |
@@ -25,2 +25,5 @@ import type { Result } from './router'; | ||
param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>; | ||
private getDecodedParam; | ||
private getAllDecodedParams; | ||
private getParamValue; | ||
query(key: string): string | undefined; | ||
@@ -27,0 +30,0 @@ query(): Record<string, string>; |
{ | ||
"name": "hono", | ||
"version": "3.12.7", | ||
"version": "3.12.8", | ||
"description": "Ultrafast web framework for the Edges", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
15012
563255