hono 2.5.0 → 2.5.1
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.
|
@@ -187,6 +187,7 @@ class VBase {
|
|
|
187
187
|
if (this._nested())
|
|
188
188
|
jsonData = dst;
|
|
189
189
|
}
|
|
190
|
+
value = this.sanitizeValue(value);
|
|
190
191
|
const results = [];
|
|
191
192
|
let typeRule = this.rules.shift();
|
|
192
193
|
for (const rule2 of this.rules) {
|
|
@@ -206,6 +207,10 @@ class VBase {
|
|
|
206
207
|
}
|
|
207
208
|
return results;
|
|
208
209
|
};
|
|
210
|
+
this.sanitizeValue = (value) => this.sanitizers.reduce(
|
|
211
|
+
(acc, sanitizer2) => sanitizer2(acc),
|
|
212
|
+
value
|
|
213
|
+
);
|
|
209
214
|
this.validateType = (value) => {
|
|
210
215
|
if (this.isArray) {
|
|
211
216
|
if (!Array.isArray(value)) {
|
|
@@ -238,9 +243,6 @@ class VBase {
|
|
|
238
243
|
if (Array.isArray(value)) {
|
|
239
244
|
if (value.length === 0 && !this._optional)
|
|
240
245
|
return false;
|
|
241
|
-
for (const sanitizer2 of this.sanitizers) {
|
|
242
|
-
value = value.map((innerVal) => sanitizer2(innerVal));
|
|
243
|
-
}
|
|
244
246
|
for (const val of value) {
|
|
245
247
|
if (!func(val)) {
|
|
246
248
|
return false;
|
|
@@ -248,9 +250,6 @@ class VBase {
|
|
|
248
250
|
}
|
|
249
251
|
return true;
|
|
250
252
|
} else {
|
|
251
|
-
for (const sanitizer2 of this.sanitizers) {
|
|
252
|
-
value = sanitizer2(value);
|
|
253
|
-
}
|
|
254
253
|
if (!func(value)) {
|
|
255
254
|
return false;
|
|
256
255
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import type { Schema, SchemaToProp } from './validator/schema';
|
|
|
6
6
|
declare type Headers = Record<string, string | string[]>;
|
|
7
7
|
declare type Runtime = 'node' | 'deno' | 'bun' | 'cloudflare' | 'fastly' | 'vercel' | 'other';
|
|
8
8
|
export declare type Data = string | ArrayBuffer | ReadableStream;
|
|
9
|
-
export declare class Context<P extends string = string, E extends Partial<Environment> = Environment, S extends Partial<Schema>
|
|
10
|
-
req: Request<P, S extends Schema ? SchemaToProp<S> :
|
|
9
|
+
export declare class Context<P extends string = string, E extends Partial<Environment> = Environment, S extends Partial<Schema> = Schema> {
|
|
10
|
+
req: Request<P, S extends Schema ? SchemaToProp<S> : S>;
|
|
11
11
|
env: E['Bindings'];
|
|
12
12
|
finalized: boolean;
|
|
13
13
|
error: Error | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,6 @@ declare type ParamKeyName<NameWithPattern> = NameWithPattern extends `${infer Na
|
|
|
17
17
|
declare type ParamKey<Component> = Component extends `:${infer NameWithPattern}` ? ParamKeyName<NameWithPattern> : never;
|
|
18
18
|
export declare type ParamKeys<Path> = Path extends `${infer Component}/${infer Rest}` ? ParamKey<Component> | ParamKeys<Rest> : ParamKey<Path>;
|
|
19
19
|
export interface CustomHandler<P extends string | Partial<Environment> | Schema = string, E = Partial<Environment> | Partial<Schema>, S = Partial<Schema>> {
|
|
20
|
-
(c: Context<P extends string ? P : P extends Partial<Environment> ? string : P extends Partial<Schema> ? string : never, P extends Partial<Environment> ? P : P extends Partial<Schema> ? Partial<Environment> : E extends Partial<Environment> ? E extends Partial<Schema> ? Environment : E : E extends Partial<Schema> ? Partial<Environment> : Environment,
|
|
20
|
+
(c: Context<P extends string ? P : P extends Partial<Environment> ? string : P extends Partial<Schema> ? string : never, P extends Partial<Environment> ? P : P extends Partial<Schema> ? Partial<Environment> : E extends Partial<Environment> ? E extends Partial<Schema> ? Environment : E : E extends Partial<Schema> ? Partial<Environment> : Environment, S extends Schema ? S : P extends Schema ? P : E extends Schema ? E : any>, next: Next): Response | Promise<Response | undefined | void>;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
|
@@ -155,6 +155,7 @@ var VBase = class {
|
|
|
155
155
|
if (this._nested())
|
|
156
156
|
jsonData = dst;
|
|
157
157
|
}
|
|
158
|
+
value = this.sanitizeValue(value);
|
|
158
159
|
const results = [];
|
|
159
160
|
let typeRule = this.rules.shift();
|
|
160
161
|
for (const rule2 of this.rules) {
|
|
@@ -174,6 +175,10 @@ var VBase = class {
|
|
|
174
175
|
}
|
|
175
176
|
return results;
|
|
176
177
|
};
|
|
178
|
+
this.sanitizeValue = (value) => this.sanitizers.reduce(
|
|
179
|
+
(acc, sanitizer2) => sanitizer2(acc),
|
|
180
|
+
value
|
|
181
|
+
);
|
|
177
182
|
this.validateType = (value) => {
|
|
178
183
|
if (this.isArray) {
|
|
179
184
|
if (!Array.isArray(value)) {
|
|
@@ -206,9 +211,6 @@ var VBase = class {
|
|
|
206
211
|
if (Array.isArray(value)) {
|
|
207
212
|
if (value.length === 0 && !this._optional)
|
|
208
213
|
return false;
|
|
209
|
-
for (const sanitizer2 of this.sanitizers) {
|
|
210
|
-
value = value.map((innerVal) => sanitizer2(innerVal));
|
|
211
|
-
}
|
|
212
214
|
for (const val of value) {
|
|
213
215
|
if (!func(val)) {
|
|
214
216
|
return false;
|
|
@@ -216,9 +218,6 @@ var VBase = class {
|
|
|
216
218
|
}
|
|
217
219
|
return true;
|
|
218
220
|
} else {
|
|
219
|
-
for (const sanitizer2 of this.sanitizers) {
|
|
220
|
-
value = sanitizer2(value);
|
|
221
|
-
}
|
|
222
221
|
if (!func(value)) {
|
|
223
222
|
return false;
|
|
224
223
|
}
|