Skip to content

Commit

Permalink
Fix: Parsing of escaped comma in querystring
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKoerner committed Oct 13, 2023
1 parent f1bec71 commit 1e8294a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/parseQueryString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import qs from 'qs';

export function parseQueryString(str: string): Record<string, unknown> {
const result = Object.create(null);
const parsed = qs.parse(str, {
// @see https://github.com/dicebear/dicebear/issues/382
const preparedStr = str.replaceAll('%2C', ',');
const parsed = qs.parse(preparedStr, {
comma: true,
plainObjects: true,
depth: 1,
Expand Down
16 changes: 16 additions & 0 deletions tests/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ for (let version of [5, 6, 7]) {
path: `/${version}.x/initials/svg/size=a`,
status: 400,
},
{
path: `/${version}.x/initials/svg?backgroundColor=000000,ffffff`,
status: 200,
},
{
path: `/${version}.x/initials/svg/backgroundColor=000000,ffffff`,
status: 200,
},
{
path: `/${version}.x/initials/svg?backgroundColor=000000%2Cffffff`,
status: 200,
},
{
path: `/${version}.x/initials/svg/backgroundColor=000000%2Cffffff`,
status: 200,
},
{
path: `/${version}.x/initials/schema.json`,
status: 200,
Expand Down

0 comments on commit 1e8294a

Please sign in to comment.