Skip to content

replace hasOwnProperty with Object.hasOwn #1329

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

Merged
merged 3 commits into from
Jun 3, 2025
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
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ name: Node CI
on:
pull_request:
branches:
- master
- v3
push:
branches:
- explore-new-api
- v3

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node: [12.20.0, 14.13.1, 16.0.0]
node: [12.20.0, 14.13.1, 16.0.0, 16, 17, 18, 19, 20, 21, 22, 23, 24]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
5 changes: 2 additions & 3 deletions lib/read-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { promisify } from 'node:util'

import Busboy from '@fastify/busboy'
import { createWriteStream } from 'fs-temp'
import hasOwnProperty from 'has-own-property'
import _onFinished from 'on-finished'
import FileType from 'stream-file-type'

Expand All @@ -29,7 +28,7 @@ function collectFields (busboy, limits) {
if (valueTruncated) return reject(new MulterError('LIMIT_FIELD_VALUE', fieldname))

// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
if (limits && hasOwnProperty(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
if (limits && Object.hasOwn(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
return reject(new MulterError('LIMIT_FIELD_KEY'))
}

Expand All @@ -54,7 +53,7 @@ function collectFiles (busboy, limits, fileFilter) {
})

// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
if (limits && hasOwnProperty(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
if (limits && Object.hasOwn(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
return reject(new MulterError('LIMIT_FIELD_KEY'))
}

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"append-field": "^2.0.0",
"bytes": "^3.1.0",
"fs-temp": "^2.0.1",
"has-own-property": "^2.0.0",
"on-finished": "^2.3.0",
"stream-file-type": "^0.6.1",
"type-is": "^1.6.18"
Expand All @@ -50,6 +49,6 @@
"lib/"
],
"scripts": {
"test": "standard && c8 --check-coverage --statements 100 mocha"
"test": "standard && c8 --check-coverage --statements 100 mocha --exit"
}
}
9 changes: 4 additions & 5 deletions test/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import stream from 'node:stream'
import { promisify } from 'node:util'

import FormData from 'form-data'
import hasOwnProperty from 'has-own-property'
import recursiveNullify from 'recursive-nullify'
import testData from 'testdata-w3c-json-form'

Expand Down Expand Up @@ -72,8 +71,8 @@ describe('body', () => {

await promisify(parser)(req, null)

assert.strictEqual(hasOwnProperty(req, 'body'), false)
assert.strictEqual(hasOwnProperty(req, 'files'), false)
assert.strictEqual(Object.hasOwn(req, 'body'), false)
assert.strictEqual(Object.hasOwn(req, 'files'), false)
})

it('should not process non-multipart GET request', async () => {
Expand All @@ -88,8 +87,8 @@ describe('body', () => {

await promisify(parser)(req, null)

assert.strictEqual(hasOwnProperty(req, 'body'), false)
assert.strictEqual(hasOwnProperty(req, 'files'), false)
assert.strictEqual(Object.hasOwn(req, 'body'), false)
assert.strictEqual(Object.hasOwn(req, 'files'), false)
})

for (const test of testData) {
Expand Down
Loading