Socket
Socket
Sign inDemoInstall

formidable

Package Overview
Dependencies
5
Maintainers
5
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.0 to 3.5.0

dist/helpers/firstValues.cjs

42

package.json
{
"name": "formidable",
"version": "3.4.0",
"version": "3.5.0",
"license": "MIT",

@@ -10,5 +10,33 @@ "description": "A node.js module for parsing form data, especially file uploads.",

"type": "module",
"main": "./src/index.js",
"main": "./dist/index.cjs",
"exports": {
".": {
"import": {
"default": "./src/index.js"
},
"require": {
"default": "./dist/index.cjs"
},
"default": "./dist/index.cjs"
},
"./src/helpers/*.js": {
"import": {
"default": "./src/helpers/*.js"
},
"require": {
"default": "./dist/helpers/*.cjs"
}
},
"./src/parsers/*.js": {
"import": {
"default": "./src/parsers/*.js"
},
"require": {
"default": "./dist/index.cjs"
}
}
},
"files": [
"src"
"src",
"dist"
],

@@ -20,2 +48,4 @@ "publishConfig": {

"scripts": {
"build-package": "rollup --config ./tool/rollup.config.js",
"prepublishOnly": "npm run build-package",
"bench": "node benchmark",

@@ -32,4 +62,5 @@ "bench2prep": "node benchmark/server.js",

"pretest": "del-cli ./test/tmp && make-dir ./test/tmp",
"test-specific": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=test/standalone/issue-46.test.js --detectOpenHandles",
"test": "npm run test-jest && npm run test-node",
"test-jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=test/ --coverage",
"test-jest": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --testPathPattern=test/ --coverage --detectOpenHandles",
"test-node": "node --test test-node/",

@@ -47,2 +78,4 @@ "pretest:ci": "yarn run pretest",

"@commitlint/config-conventional": "8.3.4",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-node-resolve": "^15.1.0",
"@sindresorhus/slugify": "^2.1.0",

@@ -66,2 +99,3 @@ "@tunnckocore/prettier-config": "1.3.8",

"prettier-plugin-pkgjson": "0.2.8",
"rollup": "^3.25.3",
"supertest": "6.1.6"

@@ -68,0 +102,0 @@ },

@@ -71,2 +71,4 @@ <p align="center">

This package is a dual ESM/commonjs package.
This project requires `Node.js >= 10.13`. Install it using

@@ -347,3 +349,3 @@ [yarn](https://yarnpkg.com) or [npm](https://npmjs.com).<br /> _We highly

- `options.filter` **{function}** - default function that always returns true.
Use it to filter files before they are uploaded. Must return a boolean.
Use it to filter files before they are uploaded. Must return a boolean. Will not make the form.parse error

@@ -376,3 +378,3 @@ - `options.createDirsFromUploads` **{boolean}** - default false. If true, makes direct folder uploads possible. Use `<input type="file" name="folders" webkitdirectory directory multiple>` to create a form to upload folders. Has to be used with the options `options.uploadDir` and `options.filename` where `options.filename` has to return a string with the character `/` for folders to be created. The base will be `options.uploadDir`.

**Note:** use an outside variable to cancel all uploads upon the first error
Behaves like Array.filter: Returning false will simply ignore the file and go to the next.

@@ -388,3 +390,22 @@ ```js

**Note:** use an outside variable to cancel all uploads upon the first error
**Note:** use form.emit('error') to make form.parse error
```js
let cancelUploads = false;// create variable at the same scope as form
const options = {
filter: function ({name, originalFilename, mimetype}) {
// keep only images
const valid = mimetype && mimetype.includes("image");
if (!valid) {
form.emit('error', new formidableErrors.default('invalid type', 0, 400)); // optional make form.parse error
cancelUploads = true; //variable to make filter return false after the first problem
}
return valid && !cancelUploads;
}
};
```
### .parse(request, ?callback)

@@ -391,0 +412,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc