You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
416 B
CoffeeScript
18 lines
416 B
CoffeeScript
endsWith = (str, suffix) -> str.indexOf(suffix, str.length - suffix.length) != -1
|
|
|
|
module.exports = (formFields) ->
|
|
correctedFormFields = {}
|
|
|
|
for fieldKey, fieldValue of formFields
|
|
newKey = switch Array.isArray fieldValue
|
|
when false then fieldKey
|
|
when true
|
|
if endsWith(fieldKey, "[]")
|
|
fieldKey
|
|
else
|
|
fieldKey + "[]"
|
|
|
|
correctedFormFields[newKey] = fieldValue
|
|
|
|
return correctedFormFields
|