fix(striker-ui-api): sanitize query string as number

main
Tsu-ba-me 2 years ago
parent fa391fd5c7
commit 43d7662c4d
  1. 2
      striker-ui-api/src/lib/sanitizeQS.ts

@ -1,5 +1,6 @@
type MapToReturnType = { type MapToReturnType = {
boolean: boolean; boolean: boolean;
number: number;
string: string; string: string;
'string[]': string[]; 'string[]': string[];
}; };
@ -12,6 +13,7 @@ type MapToReturnFunction = {
const MAP_TO_RETURN_FUNCTION: MapToReturnFunction = { const MAP_TO_RETURN_FUNCTION: MapToReturnFunction = {
boolean: (qs) => qs !== undefined, boolean: (qs) => qs !== undefined,
number: (qs) => (Number.isFinite(qs) ? parseFloat(String(qs)) : 0),
string: (qs) => (qs ? String(qs) : ''), string: (qs) => (qs ? String(qs) : ''),
'string[]': (qs) => { 'string[]': (qs) => {
let result: string[] = []; let result: string[] = [];

Loading…
Cancel
Save