Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Fix boolean true args in URL getting ignored #25950

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
7 changes: 4 additions & 3 deletions code/lib/preview-api/src/modules/store/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ describe('mapArgsToTypes', () => {
});

it('maps booleans', () => {
expect(mapArgsToTypes({ a: true }, { a: { type: booleanType } })).toStrictEqual({ a: true });
expect(mapArgsToTypes({ a: 'true' }, { a: { type: booleanType } })).toStrictEqual({ a: true });
expect(mapArgsToTypes({ a: 'false' }, { a: { type: booleanType } })).toStrictEqual({
expect(mapArgsToTypes({ a: false }, { a: { type: booleanType } })).toStrictEqual({
a: false,
});
expect(mapArgsToTypes({ a: 'yes' }, { a: { type: booleanType } })).toStrictEqual({ a: false });
Expand Down Expand Up @@ -127,7 +128,7 @@ describe('mapArgsToTypes', () => {
{
key: {
arr: ['1', '2'],
obj: { bool: 'true' },
obj: { bool: true },
},
},
{
Expand Down Expand Up @@ -157,7 +158,7 @@ describe('mapArgsToTypes', () => {
key: [
{
arr: ['1', '2'],
obj: { bool: 'true' },
obj: { bool: true },
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const map = (arg: unknown, argType: InputType): any => {
case 'number':
return Number(arg);
case 'boolean':
return arg === 'true';
return String(arg) === 'true';
case 'array':
if (!type.value || !Array.isArray(arg)) return INCOMPATIBLE;
return arg.reduce((acc, item, index) => {
Expand Down
Loading