fix(api): 🐛 Fix string query values being incorrectly casted as booleans

This commit is contained in:
Jesse Wierzbinski 2024-04-15 15:02:25 -10:00
parent 937b2c3cde
commit 6063b3ff44
No known key found for this signature in database
3 changed files with 24 additions and 11 deletions

View file

@ -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;
};