0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-29 17:46:30 +01:00

fix(client): Web query undefined check (#1340)

* Added check for undefined in query

* denofied
This commit is contained in:
Tanner Scadden 2023-08-18 03:18:21 -04:00 committed by GitHub
parent 49ce537684
commit fa1c7df42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import type { Hono } from '../hono.ts'
import type { ValidationTargets } from '../types.ts'
import type { UnionToIntersection } from '../utils/types.ts'
import type { Callback, Client, ClientRequestOptions } from './types.ts'
import { replaceUrlParam, mergePath, removeIndexString, deepMerge } from './utils.ts'
import { deepMerge, mergePath, removeIndexString, replaceUrlParam } from './utils.ts'
const createProxy = (callback: Callback, path: string[]) => {
const proxy: unknown = new Proxy(() => {}, {
@ -41,6 +41,10 @@ class ClientRequestImpl {
if (args) {
if (args.query) {
for (const [k, v] of Object.entries(args.query)) {
if (v === undefined) {
return
}
this.queryParams ||= new URLSearchParams()
if (Array.isArray(v)) {
for (const v2 of v) {

View File

@ -2,7 +2,7 @@ import type { Hono } from '../hono'
import type { ValidationTargets } from '../types'
import type { UnionToIntersection } from '../utils/types'
import type { Callback, Client, ClientRequestOptions } from './types'
import { replaceUrlParam, mergePath, removeIndexString, deepMerge } from './utils'
import { deepMerge, mergePath, removeIndexString, replaceUrlParam } from './utils'
const createProxy = (callback: Callback, path: string[]) => {
const proxy: unknown = new Proxy(() => {}, {
@ -41,6 +41,10 @@ class ClientRequestImpl {
if (args) {
if (args.query) {
for (const [k, v] of Object.entries(args.query)) {
if (v === undefined) {
return
}
this.queryParams ||= new URLSearchParams()
if (Array.isArray(v)) {
for (const v2 of v) {