diff --git a/src/request.ts b/src/request.ts index 7c028aee5..4a8ffa6b2 100644 --- a/src/request.ts +++ b/src/request.ts @@ -12,7 +12,7 @@ import type { import { parseBody } from './utils/body' import type { BodyData, ParseBodyOptions } from './utils/body' import type { UnionToIntersection } from './utils/types' -import { getQueryParam, getQueryParams, decodeURIComponent_ } from './utils/url' +import { getQueryParam, getQueryParams } from './utils/url' type Body = { json: any @@ -82,28 +82,26 @@ export class HonoRequest

{ param(key: string): string | undefined param(): UnionToIntersection>> param(key?: string): unknown { - return key ? this.getDecodedParam(key) : this.getAllDecodedParams() + return key ? this.getParam(key) : this.getAllDecodedParams() } - private getDecodedParam(key: string): string | undefined { + private getParam(key: string): string | undefined { const paramKey = this.#matchResult[0][this.routeIndex][1][key] - const param = this.getParamValue(paramKey) - - return param ? (/\%/.test(param) ? decodeURIComponent_(param) : param) : undefined + return this.getParamValue(paramKey) } private getAllDecodedParams(): Record { - const decoded: Record = {} + const params: Record = {} const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]) for (const key of keys) { const value = this.getParamValue(this.#matchResult[0][this.routeIndex][1][key]) if (value && typeof value === 'string') { - decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value + params[key] = value } } - return decoded + return params } private getParamValue(paramKey: any): string | undefined {