-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(deps): update dependency formidable to v3.5.2 #40
base: master
Are you sure you want to change the base?
Conversation
2384e4e
to
f20b866
Compare
[puLL-Merge] - node-formidable/[email protected] Diffdiff --git .eslintrc.cjs .eslintrc.cjs
index 3b6d4df6..fd6e9583 100644
--- .eslintrc.cjs
+++ .eslintrc.cjs
@@ -18,7 +18,7 @@ const ignoredProps = bestPractices.rules[
'cfg',
);
-// Additional rules that are specific and overiding previous
+// Additional rules that are specific and overriding previous
const additionalChanges = {
strict: 'off',
diff --git .github/workflows/nodejs.yml .github/workflows/nodejs.yml
index ff747ad1..2dda02de 100644
--- .github/workflows/nodejs.yml
+++ .github/workflows/nodejs.yml
@@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
- node: [14.x]
+ node: [20.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -56,7 +56,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
- node: [12.x, 14.x]
+ node: [18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
@@ -77,5 +77,5 @@ jobs:
- name: Testing
run: yarn test:ci
- name: Sending test coverage to CodeCov
- if: matrix.os == 'ubuntu-latest' && matrix.node == '14.x'
+ if: matrix.os == 'ubuntu-latest' && matrix.node == '20.x'
run: echo ${{ matrix.node }} && bash <(curl -s https://codecov.io/bash)
diff --git .gitignore .gitignore
index d20308f1..7c7ccb2c 100644
--- .gitignore
+++ .gitignore
@@ -24,6 +24,8 @@
!**/test
!**/test/**
+!**/test-node
+!**/test-node/**
!**/*tests*
!**/*tests*/**
@@ -125,3 +127,4 @@ test/tmp
# # next.js build output
# .next
+benchmark/testuploads/
diff --git CHANGELOG.md CHANGELOG.md
index fff528d0..a8b552ec 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,45 @@
# Changelog
+### 3.5.2
+
+ * fix: ([#982](https://github.com/node-formidable/formidable/pull/982)) make it easier to import hexoid with webpack
+
+### 3.5.1
+
+ * fix: ([#945](https://github.com/node-formidable/formidable/pull/945)) multipart parser fix: flush or fail always (don't hang)
+
+
+### 3.5.0
+
+ * feature: ([#944](https://github.com/node-formidable/formidable/pull/944)) Dual package: Can be imported as ES module and required as commonjs module
+
+
+### 3.4.0
+
+ * feature: ([#940](https://github.com/node-formidable/formidable/pull/940)) form.parse returns a promise if no callback is provided
+ * it resolves with an array `[fields, files]`
+
+
+### 3.3.2
+
+ * feature: ([#855](https://github.com/node-formidable/formidable/pull/855)) add options.createDirsFromUploads, see README for usage
+ * form.parse is an async function (ignore the promise)
+ * benchmarks: add e2e becnhmark with as many request as possible per second
+ * npm run to display all the commands
+ * mark as latest on npm
+
+### 3.2.5
+
+ * fix: ([#881](https://github.com/node-formidable/formidable/pull/881)) fail earlier when maxFiles is exceeded
+
+### 3.2.4
+
+ * fix: ([#857](https://github.com/node-formidable/formidable/pull/857)) improve keep extension
+ * The code from before 3.2.4 already removed some characters from the file extension. But not always. So it was inconsistent.
+ * The new code cuts the file extension at the first invalid character (invalid in a file extension).
+ * The characters that are considered invalid inside a file extension are all except the . numbers and a-Z.
+ * This change only has an effect if filename option is not used and keepextension option is used
+
### 3.2.3
@@ -46,12 +86,12 @@
### 3.0.0
- * feat: remove options.multiples ([730](https://github.com/node-formidable/formidable/pull/730))
+ * feat: remove options.multiples ([#730](https://github.com/node-formidable/formidable/pull/730))
* use modern URLSearchParams https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams internally
* files and fields values are always arrays
* fields with [] in the name do not receive special treatment
* remove unused qs and querystring dependency
- * feat: Use ES modules ([727](https://github.com/node-formidable/formidable/pull/727))
+ * feat: Use ES modules ([#727](https://github.com/node-formidable/formidable/pull/727))
* options.enabledPlugins must contain the plugin themselves instead of the plugins names
diff --git README.md README.md
index 6bf71dbe..b1f12934 100644
--- README.md
+++ README.md
@@ -20,7 +20,7 @@ at Twitter.
[![Conventional Commits][ccommits-img]][ccommits-url]
[![Minimum Required Nodejs][nodejs-img]][npmv-url]
-[![Tidelift Subcsription][tidelift-img]][tidelift-url]
+[![Tidelift Subscription][tidelift-img]][tidelift-url]
[![Buy me a Kofi][kofi-img]][kofi-url]
[![Renovate App Status][renovateapp-img]][renovateapp-url]
[![Make A Pull Request][prs-welcome-img]][prs-welcome-url]
@@ -68,6 +68,8 @@ rules, like enabling Two-Factor Auth in your npm and GitHub accounts.
## Install
+This package is a dual ESM/commonjs package.
+
This project requires `Node.js >= 10.13`. Install it using
[yarn](https://yarnpkg.com) or [npm](https://npmjs.com).<br /> _We highly
recommend to use Yarn when you think to contribute to this project._
@@ -77,14 +79,14 @@ already be included. Check the examples below and the [examples/](https://github
\`\`\`
# v2
-npm install formidable
npm install formidable@v2
# v3
+npm install formidable
npm install formidable@v3 -Note: In the near future v3 will be published on the Examples@@ -98,23 +100,28 @@ Parse an incoming file upload, with the import http from 'node:http';
-import formidable from 'formidable';
+import formidable, {errors as formidableErrors} from 'formidable';
-const server = http.createServer((req, res) => {
+const server = http.createServer(async (req, res) => {
if (req.url === '/api/upload' && req.method.toLowerCase() === 'post') {
// parse a file upload
const form = formidable({});
+ let fields;
+ let files;
+ try {
+ [fields, files] = await form.parse(req);
+ } catch (err) {
+ // example to check for a very specific error
+ if (err.code === formidableErrors.maxFieldsExceeded) {
- form.parse(req, (err, fields, files) => {
- if (err) {
+ }
+ console.error(err);
res.writeHead(err.httpCode || 400, { 'Content-Type': 'text/plain' });
res.end(String(err));
return;
- }
- res.writeHead(200, { 'Content-Type': 'application/json' });
- res.end(JSON.stringify({ fields, files }, null, 2));
- });
-
+ }
+ res.writeHead(200, { 'Content-Type': 'application/json' });
+ res.end(JSON.stringify({ fields, files }, null, 2));
return;
}
@@ -338,7 +345,9 @@ See it's defaults in [src/Formidable.js DEFAULT_OPTIONS](./src/Formidable.js)
newFilename. Must return a string. Will be joined with options.uploadDir.
- `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
+
+- `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`.
#### `options.filename` **{function}** function (name, ext, part, form) -> string
@@ -364,7 +373,7 @@ form.bytesExpected;
#### `options.filter` **{function}** function ({name, originalFilename, mimetype}) -> boolean
-**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.
```js
const options = {
@@ -375,11 +384,29 @@ const options = {
}; +Note: use an outside variable to cancel all uploads upon the first error -### .parse(request, callback) -Parses an incoming Node.js
+### .parse(request, ?callback) const form = formidable({ uploadDir: __dirname });
@@ -388,6 +415,9 @@ form.parse(req, (err, fields, files) => {
console.log('fields:', fields);
console.log('files:', files);
});
+
+// with Promise
+const [fields, files] = await form.parse(req); You may overwrite this method if you are interested in directly accessing the .use(plugin: Plugin)A method that allows you to extend the Formidable library. By default we include The plugins added by this method are always enabled. @@ -644,7 +674,7 @@ form.on('fileBegin', (formName, file) => {
DescriptionThis PR introduces several significant changes to the formidable package, including dual ESM/CommonJS module support, Node.js version requirement updates, folder upload support, promise-based API, and various bug fixes. The main motivation appears to be modernizing the codebase and improving functionality. ChangesChangesPackage Configuration:
Core Functionality:
Documentation:
Tests:
sequenceDiagram
participant Client
participant Server
participant Formidable
participant FileSystem
Client->>Server: POST /upload
Server->>Formidable: form.parse(req)
alt Using Promises
Formidable->>Formidable: Parse Headers
Formidable->>Formidable: Process Parts
alt createDirsFromUploads enabled
Formidable->>FileSystem: Create Directory Structure
end
Formidable->>FileSystem: Write Files
Formidable-->>Server: Resolve Promise [fields, files]
else Using Callback
Formidable->>Formidable: Parse Headers
Formidable->>Formidable: Process Parts
opt createDirsFromUploads enabled
Formidable->>FileSystem: Create Directory Structure
end
Formidable->>FileSystem: Write Files
Formidable-->>Server: Execute Callback(err, fields, files)
end
Server-->>Client: Response
Security Hotspots
Possible Issues
|
This PR contains the following updates:
3.2.4
->3.5.2
Release Notes
node-formidable/formidable (formidable)
v3.5.2
Compare Source
v3.5.1
Compare Source
v3.5.0
Compare Source
v3.4.0
Compare Source
[fields, files]
v3.3.2
Compare Source
v3.2.5
Compare Source
Configuration
📅 Schedule: Branch creation - "* * * * 2-4" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.