From 7d706f9ccfc22aa59a1f241112766b2b3c073624 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 24 Aug 2026 19:56:26 +0000 Subject: [PATCH 1/2] fix: Use the object form paramsSerializer in the request url The url getter only honored a function form paramsSerializer and silently fell back to the SDK serializer for the object form axios also accepts, so the inspected request URL diverged from the URL actually sent on the wire. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2 --- src/lib/seam-http-request.ts | 10 ++++--- test/seam/connect/seam-http-request.test.ts | 30 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/lib/seam-http-request.ts b/src/lib/seam-http-request.ts index 719de08d..c53bbf16 100644 --- a/src/lib/seam-http-request.ts +++ b/src/lib/seam-http-request.ts @@ -80,10 +80,14 @@ export class SeamHttpRequest< public get url(): URL { const { client } = this.#parent + const { paramsSerializer } = client.defaults + const serializer = - typeof client.defaults.paramsSerializer === 'function' - ? client.defaults.paramsSerializer - : serializeUrlSearchParams + typeof paramsSerializer === 'function' + ? paramsSerializer + : typeof paramsSerializer?.serialize === 'function' + ? paramsSerializer.serialize + : serializeUrlSearchParams const origin = getUrlPrefix(client.defaults.baseURL ?? '') diff --git a/test/seam/connect/seam-http-request.test.ts b/test/seam/connect/seam-http-request.test.ts index 00e69b5d..52a30f16 100644 --- a/test/seam/connect/seam-http-request.test.ts +++ b/test/seam/connect/seam-http-request.test.ts @@ -172,6 +172,36 @@ test.serial( }, ) +test('SeamHttpRequest: url uses a custom function form paramsSerializer', async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: 'https://example.com', + axiosOptions: { + paramsSerializer: () => 'custom=function', + }, + }) + + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.is(url.search, '?custom=function') +}) + +test('SeamHttpRequest: url uses a custom object form paramsSerializer', async (t) => { + const { seed } = await getTestServer(t) + const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { + endpoint: 'https://example.com', + axiosOptions: { + paramsSerializer: { + serialize: () => 'custom=object', + }, + }, + }) + + const { url } = seam.devices.get({ device_id: 'abc123' }) + + t.is(url.search, '?custom=object') +}) + const toPlainUrlObject = (url: URL): Omit => { return { pathname: url.pathname, From f8723a8fd7c39ca3c5878a886ca80b041760ca5d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 24 Aug 2026 23:11:09 +0000 Subject: [PATCH 2/2] refactor: Select the params serializer without nested ternaries Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2 --- src/lib/seam-http-request.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/seam-http-request.ts b/src/lib/seam-http-request.ts index c53bbf16..6682f463 100644 --- a/src/lib/seam-http-request.ts +++ b/src/lib/seam-http-request.ts @@ -80,14 +80,7 @@ export class SeamHttpRequest< public get url(): URL { const { client } = this.#parent - const { paramsSerializer } = client.defaults - - const serializer = - typeof paramsSerializer === 'function' - ? paramsSerializer - : typeof paramsSerializer?.serialize === 'function' - ? paramsSerializer.serialize - : serializeUrlSearchParams + const serializer = getParamsSerializer(client.defaults.paramsSerializer) const origin = getUrlPrefix(client.defaults.baseURL ?? '') @@ -226,6 +219,16 @@ export class SeamHttpRequest< } } +const getParamsSerializer = ( + paramsSerializer: Client['defaults']['paramsSerializer'], +): ((params: Record) => string) => { + if (typeof paramsSerializer === 'function') return paramsSerializer + if (typeof paramsSerializer?.serialize === 'function') { + return paramsSerializer.serialize + } + return serializeUrlSearchParams +} + const getUrlPrefix = (input: string): string => { if (canParseUrl(input)) { const url = new URL(input).toString()