diff --git a/src/content-types/urlencoded.ts b/src/content-types/urlencoded.ts index 47ae205..814c00d 100644 --- a/src/content-types/urlencoded.ts +++ b/src/content-types/urlencoded.ts @@ -1,7 +1,7 @@ -import { type ParsedUrlQuery, parse } from 'node:querystring' import { ContentType } from '@otterhttp/content-type' import { type ReadOptions, getRead } from '@/get-read' +import { type ParsedUrlQuery, parseUrlQuery } from '@/parsers/urlencoded' import type { MaybeParsed, Request, Response } from '@/types' import { alreadyParsed } from '@/utils/already-parsed-symbol' import { compose } from '@/utils/compose-functions' @@ -46,7 +46,7 @@ export function makeUrlencoded((x) => parse(x), optionsCopy) + const read = getRead((x) => parseUrlQuery(x), optionsCopy) return async (req: Req & MaybeParsed, res: Res): Promise => { if (req[alreadyParsed] === true) return undefined if (hasNoBody(req.method)) return undefined diff --git a/src/parsers/index.ts b/src/parsers/index.ts index 7e2a26e..5fd7f15 100644 --- a/src/parsers/index.ts +++ b/src/parsers/index.ts @@ -1,4 +1,4 @@ -export * from "./http-headers" -export * from "./multipart" -export * from "./multipart-form-data" -export * from "./urlencoded" \ No newline at end of file +export * from './http-headers' +export * from './multipart' +export * from './multipart-form-data' +export * from './urlencoded' diff --git a/src/parsers/urlencoded.ts b/src/parsers/urlencoded.ts index 6becdfb..07acf15 100644 --- a/src/parsers/urlencoded.ts +++ b/src/parsers/urlencoded.ts @@ -1 +1 @@ -export { type ParsedUrlQuery, parse as parseUrlQuery } from "node:querystring" +export { type ParsedUrlQuery, parse as parseUrlQuery } from 'node:querystring' diff --git a/src/types.ts b/src/types.ts index e592905..4a12ec8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -11,4 +11,4 @@ export type Response = Server // https://stackoverflow.com/a/76616671 export type Omit = { [P in keyof T as Exclude]: T[P] } -export type * from "@/parsers" +export type * from '@/parsers' diff --git a/tests/custom.test.ts b/tests/custom.test.ts index 03c7870..42dc5a7 100644 --- a/tests/custom.test.ts +++ b/tests/custom.test.ts @@ -25,6 +25,4 @@ test('should parse custom body', async () => { }).expect(200, 'HELLO WORLD') }) -test.skip('custom should ignore GET request', async () => { - -}) +test.skip('custom should ignore GET request', async () => {}) diff --git a/tests/json.test.ts b/tests/json.test.ts index d9a52da..20d26d6 100644 --- a/tests/json.test.ts +++ b/tests/json.test.ts @@ -108,9 +108,7 @@ it('should not parse json body with no content-type headers', async () => { await expect(response.text()).resolves.toEqual('') }) -it.skip('should ignore GET requests', async () => { - -}) +it.skip('should ignore GET requests', async () => {}) describe('with invalid JSON body', () => { it('should 400 when body consists only of whitespace', async () => { diff --git a/tests/raw.test.ts b/tests/raw.test.ts index 76211a3..077d01b 100644 --- a/tests/raw.test.ts +++ b/tests/raw.test.ts @@ -25,6 +25,4 @@ test('should parse raw body', async () => { }).expect(200, 'hello world') }) -test.skip('raw should ignore GET request', async () => { - -}) +test.skip('raw should ignore GET request', async () => {}) diff --git a/tests/text.test.ts b/tests/text.test.ts index b18301c..b3f5a78 100644 --- a/tests/text.test.ts +++ b/tests/text.test.ts @@ -25,6 +25,4 @@ test('should parse text body', async () => { }).expect(200, 'hello world') }) -test.skip('text should ignore GET request', async () => { - -}) +test.skip('text should ignore GET request', async () => {}) diff --git a/tests/urlencoded.test.ts b/tests/urlencoded.test.ts index a0e797d..4ded68f 100644 --- a/tests/urlencoded.test.ts +++ b/tests/urlencoded.test.ts @@ -25,6 +25,4 @@ test('should parse urlencoded body', async () => { }).expect(200, { hello: 'world' }) }) -test.skip('urlencoded should ignore GET request', async () => { - -}) +test.skip('urlencoded should ignore GET request', async () => {})