Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/violet-rocks-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/clerk-js": patch
---

Bug fix: Requests failing due to incorrect parsing of value `false` when content type is `x-www-form-urlencoded`
4 changes: 4 additions & 0 deletions packages/clerk-js/src/utils/__tests__/querystring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ describe('stringifyQueryParams(object)', () => {
expect(stringifyQueryParams({ test: 'ena=duo' })).toBe('test=ena%3Dduo');
});

it('handles false value', () => {
expect(stringifyQueryParams({ test: false, boo: true })).toBe('test=false&boo=true');
});

it('converts an object to querystring when key is camelCase', () => {
expect(stringifyQueryParams({ barFoo: '1' }, { keyEncoder: camelToSnake })).toBe('bar_foo=1');
expect(stringifyQueryParams({ unsafeMetadata: { bar: '1' } }, { keyEncoder: camelToSnake })).toBe(
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/utils/querystring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type StringifyQueryParamsOptions = {

export const stringifyQueryParams = (
params:
| Record<string, string | undefined | null | object | Array<string | undefined | null>>
| Record<string, string | undefined | null | object | boolean | Array<string | undefined | null>>
| null
| undefined
| string,
Expand All @@ -48,7 +48,7 @@ export const stringifyQueryParams = (
} else if (typeof value === 'object' && value !== null) {
queryParams.append(encodedKey, JSON.stringify(value));
} else {
queryParams.append(encodedKey, value || '');
queryParams.append(encodedKey, String(value ?? ''));
}
});

Expand Down