diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a66265a..1d404ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Setting up the environment -This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install). +This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable). Other package managers may work but are not officially supported for development. To set up the repository, run: @@ -29,10 +29,10 @@ All files in the `examples/` directory are not modified by the generator and can … ``` -```sh -$ chmod +x examples/.ts +``` +chmod +x examples/.ts # run the example against your api -$ yarn tsn -T examples/.ts +yarn tsn -T examples/.ts ``` ## Using the repository from source diff --git a/src/core.ts b/src/core.ts index e21ab9f..21bac9a 100644 --- a/src/core.ts +++ b/src/core.ts @@ -522,19 +522,9 @@ export abstract class APIClient { const timeout = setTimeout(() => controller.abort(), ms); - const fetchOptions = { - signal: controller.signal as any, - ...options, - }; - if (fetchOptions.method) { - // Custom methods like 'patch' need to be uppercased - // See https://github.com/nodejs/undici/issues/2294 - fetchOptions.method = fetchOptions.method.toUpperCase(); - } - return ( // use undefined this binding; fetch errors if bound to something else in browser/cloudflare - this.fetch.call(undefined, url, fetchOptions).finally(() => { + this.fetch.call(undefined, url, { signal: controller.signal as any, ...options }).finally(() => { clearTimeout(timeout); }) ); diff --git a/tests/index.test.ts b/tests/index.test.ts index 3a36ecd..2cb0dd2 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -122,23 +122,6 @@ describe('instantiate client', () => { expect(spy).toHaveBeenCalledTimes(1); }); - test('normalized method', async () => { - let capturedRequest: RequestInit | undefined; - const testFetch = async (url: RequestInfo, init: RequestInit = {}): Promise => { - capturedRequest = init; - return new Response(JSON.stringify({}), { headers: { 'Content-Type': 'application/json' } }); - }; - - const client = new Browserbase({ - baseURL: 'http://localhost:5000/', - apiKey: 'My API Key', - fetch: testFetch, - }); - - await client.patch('/foo'); - expect(capturedRequest?.method).toEqual('PATCH'); - }); - describe('baseUrl', () => { test('trailing slash', () => { const client = new Browserbase({ baseURL: 'http://localhost:5000/custom/path/', apiKey: 'My API Key' });