mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
fix(api): 🐛 Fix string query values being incorrectly casted as booleans
This commit is contained in:
parent
937b2c3cde
commit
6063b3ff44
3 changed files with 24 additions and 11 deletions
|
|
@ -173,11 +173,23 @@ export class RequestParser {
|
|||
}
|
||||
(result[arrayKey] as string[]).push(decodeURIComponent(value));
|
||||
} else {
|
||||
result[key as keyof T] = decodeURIComponent(
|
||||
value,
|
||||
result[key as keyof T] = castBoolean(
|
||||
decodeURIComponent(value),
|
||||
) as T[keyof T];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const castBoolean = (value: string) => {
|
||||
if (["true"].includes(value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (["false"].includes(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue