Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-pots-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jhecht/arktype-utils": patch
---

Fixes faulty logic in parse key causing names to only be the first character.
14 changes: 7 additions & 7 deletions packages/arktype-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
```ts
// Test nested objects with dot notation
const fd = new FormData();
fd.append("payments.id1.location", "England");
fd.append("payments.id1.age", "37");
fd.append("payments.id2.location", "New York");
fd.append('payments.id1.location', 'England');
fd.append('payments.id1.age', '37');
fd.append('payments.id2.location', 'New York');
const obj = formDataToObject(fd);

// Test nested arrays with bracket notation
const fd2 = new FormData();
fd2.append("locations[].name", "England");
fd2.append("locations[].members[]", "John");
fd2.append("locations[].members[]", "Joe");
fd2.append("locations[].name", "France");
fd2.append('locations[].name', 'England');
fd2.append('locations[].members[]', 'John');
fd2.append('locations[].members[]', 'Joe');
fd2.append('locations[].name', 'France');
const obj2 = formDataToObject(fd2);
```

Expand Down
2 changes: 1 addition & 1 deletion packages/arktype-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"scripts": {
"test": "vitest --coverage",
"test:ci": "vitest run --coverage --changed",
"test:ci": "vitest run --coverage",
"build": "tsup src/index.ts --format cjs,esm --dts",
"lint": "eslint src/**/*.ts",
"prepublishOnly": "pnpm run build"
Expand Down
3 changes: 2 additions & 1 deletion packages/arktype-utils/src/formData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function parseKeyPath(key: string): (string | number)[] {
let buffer = '';
let inBracket = false;
for (let i = 0; i < key.length; i++) {
const [char] = key;
// eslint-disable-next-line @jhecht/prefer-destructuring
const char = key[i];
if (char === '[') {
if (buffer) {
path.push(buffer);
Expand Down
Loading