Skip to content

Commit

Permalink
style: check:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordfirespeed committed Sep 23, 2024
1 parent 3f4a610 commit faa2536
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/content-types/urlencoded.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -46,7 +46,7 @@ export function makeUrlencoded<Req extends Request = Request, Res extends Respon

const matcher = options?.matcher ?? typeChecker(ContentType.parse('application/*+x-www-form-urlencoded'))

const read = getRead<ParsedUrlQuery>((x) => parse(x), optionsCopy)
const read = getRead<ParsedUrlQuery>((x) => parseUrlQuery(x), optionsCopy)
return async (req: Req & MaybeParsed, res: Res): Promise<ParsedUrlQuery | undefined> => {
if (req[alreadyParsed] === true) return undefined
if (hasNoBody(req.method)) return undefined
Expand Down
8 changes: 4 additions & 4 deletions src/parsers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "./http-headers"
export * from "./multipart"
export * from "./multipart-form-data"
export * from "./urlencoded"
export * from './http-headers'
export * from './multipart'
export * from './multipart-form-data'
export * from './urlencoded'
2 changes: 1 addition & 1 deletion src/parsers/urlencoded.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { type ParsedUrlQuery, parse as parseUrlQuery } from "node:querystring"
export { type ParsedUrlQuery, parse as parseUrlQuery } from 'node:querystring'
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export type Response<Request extends IncomingMessage = IncomingMessage> = Server
// https://stackoverflow.com/a/76616671
export type Omit<T, K extends PropertyKey> = { [P in keyof T as Exclude<P, K>]: T[P] }

export type * from "@/parsers"
export type * from '@/parsers'
4 changes: 1 addition & 3 deletions tests/custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {})
4 changes: 1 addition & 3 deletions tests/json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 1 addition & 3 deletions tests/raw.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {})
4 changes: 1 addition & 3 deletions tests/text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {})
4 changes: 1 addition & 3 deletions tests/urlencoded.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {})

0 comments on commit faa2536

Please sign in to comment.