Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decode-formdata

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decode-formdata - npm Package Compare versions

Comparing version 0.7.5 to 0.8.0

20

dist/index.js

@@ -122,7 +122,23 @@ // src/regex.ts

const [info, transform] = typeof arg2 === "function" ? [void 0, arg2] : [arg2, arg3];
if (info) {
for (const key of [
"arrays",
"booleans",
"dates",
"files",
"numbers"
]) {
if (info[key]?.length) {
info[key] = info[key].map(
(templateName) => templateName.replace(/\[\$\]/g, ".$")
);
}
}
}
const values = {};
for (const [path, input] of formData.entries()) {
const templateName = path.replace(/\.\d+\./g, ".$.").replace(/\.\d+$/, ".$");
const normlizedPath = path.replace(/\[(\d+)\]/g, ".$1");
const templateName = normlizedPath.replace(/\.\d+\./g, ".$.").replace(/\.\d+$/, ".$");
const templateKeys = templateName.split(".");
path.split(".").reduce((object, key, index, keys) => {
normlizedPath.split(".").reduce((object, key, index, keys) => {
if (index < keys.length - 1) {

@@ -129,0 +145,0 @@ if (object[key]) {

2

package.json
{
"name": "decode-formdata",
"description": "Decodes complex FormData into a JavaScript object",
"version": "0.7.5",
"version": "0.8.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": "Fabian Hiller",

@@ -34,4 +34,6 @@ # Decode FormData

Another problem are objects and arrays, which are usually mapped using dot notation. For example, the input field `<input name="todos.0.label" />` should map to the object `{ todos: [{ label: "" }] }`. By telling `decode` where arrays, booleans, dates, files, and numbers are located, the function can decode your `FormData` back into a complex JavaScript object.
Another problem are objects and arrays, which are usually mapped using dot and bracket notation. For example, the input field `<input name="todos.0.label" />` should map to the object `{ todos: [{ label: "" }] }`. By telling `decode` where arrays, booleans, dates, files, and numbers are located, the function can decode your `FormData` back into a complex JavaScript object.
> Both dot and bracket notation are supported for arrays.
Consider the following form to add a new product to an online store:

@@ -178,1 +180,5 @@

This project is available free of charge and licensed under the [MIT license](https://github.com/fabian-hiller/decode-formdata/blob/main/LICENSE.md).
## Note
Both dot and bracket notation are supported for arrays.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc