Skip to content

Commit a1aac4d

Browse files
committed
fix: 🍺 allow more http methods
1 parent a1d331a commit a1aac4d

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/__tests__/post-proxy.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('PostProxy', () => {
4848
await proxy.throwException(1)
4949
} catch (e: any) {
5050
expect(e.message).toEqual(
51-
'`unlink` is not a valid request type, must be one of: `get`, `delete`, `head`, `post`, `put`, `patch`.',
51+
'`unlink` is not a valid request type, must be one of: `get`, `GET`, `delete`, `DELETE`, `head`, `HEAD`, `options`, `OPTIONS`, `post`, `POST`, `put`, `PUT`, `patch`, `PATCH`.',
5252
)
5353
}
5454
})

src/core/BaseProxy.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class BaseProxy {
221221
})
222222
}
223223

224-
private __getParameterString(url: string): string {
224+
private __getParameterString(url: string) {
225225
const query = qs.stringify(this.parameters, {
226226
encode: false,
227227
skipNulls: true,
@@ -230,9 +230,24 @@ class BaseProxy {
230230
return `${url}${query}`
231231
}
232232

233-
private static __validateRequestType(requestType: Method): Method {
234-
const requestTypes = ['get', 'delete', 'head', 'post', 'put', 'patch']
235-
if (!requestTypes.includes(requestType.toLowerCase())) {
233+
private static __validateRequestType(requestType: Method) {
234+
const requestTypes: Method[] = [
235+
'get',
236+
'GET',
237+
'delete',
238+
'DELETE',
239+
'head',
240+
'HEAD',
241+
'options',
242+
'OPTIONS',
243+
'post',
244+
'POST',
245+
'put',
246+
'PUT',
247+
'patch',
248+
'PATCH',
249+
]
250+
if (!requestTypes.includes(requestType)) {
236251
throw new Error(
237252
`\`${requestType}\` is not a valid request type, ` +
238253
`must be one of: \`${requestTypes.join('`, `')}\`.`,

0 commit comments

Comments
 (0)