improve parseQueryString function
This commit is contained in:
@@ -4,7 +4,8 @@ export const parseQueryString = (obj: Record<string, any>): any => {
|
|||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
Object.entries(obj).map(([k, v]) => {
|
Object.entries(obj).map(([k, v]) => {
|
||||||
if (typeof v === 'object') return [k, parseQueryString(v)];
|
if (typeof v === 'object') return [k, parseQueryString(v)];
|
||||||
if (!isNaN(parseFloat(v))) return [k, parseFloat(v)];
|
if (/^-?[0-9]+(\.[0-9]+)?$/i.test(v) && !isNaN(parseFloat(v)))
|
||||||
|
return [k, parseFloat(v)];
|
||||||
if (v === 'true') return [k, true];
|
if (v === 'true') return [k, true];
|
||||||
if (v === 'false') return [k, false];
|
if (v === 'false') return [k, false];
|
||||||
if (typeof v === 'string') {
|
if (typeof v === 'string') {
|
||||||
|
|||||||
Reference in New Issue
Block a user