Skip to content

Commit

Permalink
URI decode resourceId (#1791)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomassnielsen authored Oct 21, 2024
1 parent ed6ea50 commit 5c84e65
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/server/src/api/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1231,15 +1231,16 @@ class RequestHandler extends APIHandlerBase {
}

private makePrismaIdFilter(idFields: FieldInfo[], resourceId: string) {
const decodedId = decodeURIComponent(resourceId);
if (idFields.length === 1) {
return { [idFields[0].name]: this.coerce(idFields[0].type, resourceId) };
return { [idFields[0].name]: this.coerce(idFields[0].type, decodedId) };
} else {
return {
// TODO: support `@@id` with custom name
[idFields.map((idf) => idf.name).join(prismaIdDivider)]: idFields.reduce(
(acc, curr, idx) => ({
...acc,
[curr.name]: this.coerce(curr.type, resourceId.split(this.idDivider)[idx]),
[curr.name]: this.coerce(curr.type, decodedId.split(this.idDivider)[idx]),
}),
{}
),
Expand Down

0 comments on commit 5c84e65

Please sign in to comment.