Skip to content

Commit

Permalink
fix: bug in param handeling
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Apr 27, 2024
1 parent 9685e08 commit 083b77e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const CoCreateApi = {

// TODO: handle $param operator
getData: async function ({ name, method, element, form }) {
const data = {}
let data = {}

if (!form && element)
form = element.closest('form');
Expand All @@ -148,17 +148,17 @@ const CoCreateApi = {

let params = {}, hasParams = false
for (let i = 0; true; i++) {
if (`$param[${i}]` in data[name]) {
params[`$param[${i}]`] = data[name][`$param[${i}]`]
delete data[name][`$param[${i}]`]
if (`$param[${i}]` in data) {
params[`$param[${i}]`] = data[`$param[${i}]`]
delete data[`$param[${i}]`]
hasParams = true
} else {
break;
}
}
data = dotNotationToObject(data);
if (hasParams)
data[name] = { ...params, ...data[name] }
data = { ...params, ...data }

return data
},
Expand Down

0 comments on commit 083b77e

Please sign in to comment.