remix-params-helper
Advanced tools
Comparing version 0.4.9 to 0.4.10
@@ -29,2 +29,7 @@ "use strict"; | ||
} | ||
let isArray = false; | ||
if (key.includes('[]')) { | ||
isArray = true; | ||
key = key.replace('[]', ''); | ||
} | ||
const def = shape[key]; | ||
@@ -34,13 +39,2 @@ if (def) { | ||
} | ||
else { | ||
if (o.hasOwnProperty(key)) { | ||
if (!Array.isArray(o[key])) { | ||
o[key] = [o[key]]; | ||
} | ||
o[key].push(value); | ||
} | ||
else { | ||
o[key] = value; | ||
} | ||
} | ||
} | ||
@@ -62,4 +56,2 @@ function getParamsInternal(params, schema) { | ||
} | ||
// remove [] from key since we already handle multi-value params | ||
key = key.replace(/\[\]/g, ''); | ||
parseParams(o, schema, key, value); | ||
@@ -66,0 +58,0 @@ } |
@@ -26,2 +26,7 @@ import { ZodArray, ZodBoolean, ZodDate, ZodDefault, ZodEffects, ZodEnum, ZodLiteral, ZodNativeEnum, ZodNumber, ZodObject, ZodOptional, ZodString, } from 'zod'; | ||
} | ||
let isArray = false; | ||
if (key.includes('[]')) { | ||
isArray = true; | ||
key = key.replace('[]', ''); | ||
} | ||
const def = shape[key]; | ||
@@ -31,13 +36,2 @@ if (def) { | ||
} | ||
else { | ||
if (o.hasOwnProperty(key)) { | ||
if (!Array.isArray(o[key])) { | ||
o[key] = [o[key]]; | ||
} | ||
o[key].push(value); | ||
} | ||
else { | ||
o[key] = value; | ||
} | ||
} | ||
} | ||
@@ -59,4 +53,2 @@ function getParamsInternal(params, schema) { | ||
} | ||
// remove [] from key since we already handle multi-value params | ||
key = key.replace(/\[\]/g, ''); | ||
parseParams(o, schema, key, value); | ||
@@ -63,0 +55,0 @@ } |
{ | ||
"name": "remix-params-helper", | ||
"version": "0.4.9", | ||
"version": "0.4.10", | ||
"description": "This package makes it simple to use Zod with standard URLSearchParams and FormData which are typically used in Remix apps.", | ||
@@ -5,0 +5,0 @@ "browser": "/dist/helper.js", |
@@ -46,15 +46,10 @@ import { | ||
} | ||
let isArray = false | ||
if (key.includes('[]')) { | ||
isArray = true | ||
key = key.replace('[]', '') | ||
} | ||
const def = shape[key] | ||
if (def) { | ||
processDef(def, o, key, value as string) | ||
} else { | ||
if (o.hasOwnProperty(key)) { | ||
if (!Array.isArray(o[key])) { | ||
o[key] = [o[key]] | ||
} | ||
o[key].push(value) | ||
} else { | ||
o[key] = value | ||
} | ||
} | ||
@@ -82,4 +77,2 @@ } | ||
} | ||
// remove [] from key since we already handle multi-value params | ||
key = key.replace(/\[\]/g, '') | ||
parseParams(o, schema, key, value) | ||
@@ -86,0 +79,0 @@ } |
39674
821