Skip to content

Commit

Permalink
fix: import iconv-lite using namespace import
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordfirespeed committed Aug 25, 2024
1 parent f1c93bc commit 87c3404
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/get-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { finished } from 'node:stream/promises'
import * as zlib from 'node:zlib'
import { ClientError, HttpError, ServerError } from '@otterhttp/errors'
import { parse as parseBytes } from 'bytes'
import { encodingExists as charsetExists, decode as iconvDecode } from 'iconv-lite'

import { charsetExists, decodeCharset } from '@/utils/iconv'
import { alreadyParsed } from '@/utils/already-parsed-symbol'
import { ClientCharsetError, ClientEncodingError, ParseFailedError, VerifyFailedError } from '@/utils/errors'
import { getCharset } from '@/utils/get-request-charset'
Expand Down Expand Up @@ -215,7 +215,7 @@ export const getRead = <T = unknown>(parseFunction: (body: string) => T | Promis

let body: string
try {
body = iconvDecode(bodyBlob, requestCharset)
body = decodeCharset(bodyBlob, requestCharset)
} catch (err) {
throw new ClientError(`request body does not adhere to charset '${requestCharset}'`, {
statusCode: 400,
Expand Down
4 changes: 4 additions & 0 deletions src/utils/iconv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as iconv from "iconv-lite"

export const charsetExists = iconv.encodingExists
export const decodeCharset = iconv.decode

0 comments on commit 87c3404

Please sign in to comment.