Skip to content

Commit

Permalink
fix(http): ignore nullable in search params, fix satorijs/satori#262
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 15, 2024
1 parent 59db019 commit e8a216a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "undios",
"description": "Fetch-based axios-style HTTP client",
"version": "0.1.9",
"version": "0.3.3",
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Context, Service } from 'cordis'
import { Awaitable, defineProperty, Dict, trimSlash } from 'cosmokit'
import { Awaitable, defineProperty, Dict, isNullable, trimSlash } from 'cosmokit'
import { ClientOptions } from 'ws'
import { WebSocket } from 'undios/adapter'
import { ReadableStream } from 'node:stream/web'

export type { WebSocket } from 'undios/adapter'

Expand Down Expand Up @@ -161,7 +162,7 @@ export class HTTP extends Service<HTTP.Config> {
this.decoder('blob', (raw) => raw.blob())
this.decoder('arraybuffer', (raw) => raw.arrayBuffer())
this.decoder('formdata', (raw) => raw.formData())
this.decoder('stream', (raw) => raw.body!)
this.decoder('stream', (raw) => raw.body as any)
}

static mergeConfig = (target: HTTP.Config, source?: HTTP.Config) => ({
Expand Down Expand Up @@ -215,6 +216,7 @@ export class HTTP extends Service<HTTP.Config> {
throw new TypeError(`Invalid URL: ${url}`)
}
for (const [key, value] of Object.entries(config.params ?? {})) {
if (isNullable(value)) continue
url.searchParams.append(key, value)
}
return url
Expand Down

0 comments on commit e8a216a

Please sign in to comment.