1250 Commits

Author SHA1 Message Date
Murat Kirazkaya
9c85a25c02 Remove duplicate tests in res.location and res.jsonp (#6996)
* test: remove duplicated tests

* test: fix typo in data URI encoding test description
2026-02-14 12:25:36 -05:00
Ayoub Mabrouk
6b7ccfcf12 test: add test for normalizeType fallback when mime lookup fails (#6894)
Add test to verify that utils.normalizeType correctly defaults to
'application/octet-stream' when mime.lookup() returns null/undefined
for unknown file extensions. This covers the fallback behavior on
line 64 of lib/utils.js and ensures proper handling of unrecognized
MIME types.

Co-authored-by: bjohansebas <103585995+bjohansebas@users.noreply.github.com>
2026-01-31 21:53:38 -05:00
AkaHarshit
c9ecf7b658 feat: Allow passing null or undefined as the value for options in app.render (#6903)
* fix: allow null options in app.render

* fix: ensure options are initialized to an empty object in app.render

* docs: add history entry

---------

Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
2026-01-31 21:51:17 -05:00
sukdev24
912893c07c test: added unit tests for utils.compileETag to cover valid and invalid inputs (#6534)
* Added unit tests for utils.compileETag to cover valid and invalid inputs

* test: enhance compileETag tests for various input types

---------

Co-authored-by: sucem029 <sucem029@vippan-118.ad.liu.se>
Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
2026-01-16 21:27:22 -05:00
Bernice Wu
9a3f7ff412 Polish HTML structure of the response in the res.redirect() function (#5167)
* structure the DOM body

* structure the DOM body

* test: add html title to redirect test

* fix: update HTML structure for include body and head tags

* docs: improve HTML structure in res.redirect() responses for better browser compatibility

---------

Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
2026-01-16 10:29:01 -05:00
AbdelMonaam Aouini
6cd404eb28 fix: enhance req.acceptsCharsets method (#6088)
* fix: enhance req.acceptsCharsets method

* Update req.acceptsCharsets.js

---------

Co-authored-by: Monaam Aouini <abdelmonaem.aouini@mispay.co>
Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
2026-01-07 09:41:34 -05:00
Ulises Gascon
697547cde6 Revert "sec: security patch for CVE-2024-51999"
This reverts commit 2f64f68c37.
2025-12-01 15:27:35 -05:00
Chris de Almeida
2f64f68c37 sec: security patch for CVE-2024-51999 2025-12-01 17:15:17 +01:00
Sebastian Beltran
89f198c6a5 lib: use req.socket over deprecated req.connection (#6705)
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
2025-08-21 10:05:29 -05:00
mountdisk
b0ed15b452 chore: fix typo (#6609)
Signed-off-by: mountdisk <mountdisk@icloud.com.>
2025-07-04 09:47:31 -05:00
Shivam Sharma
98c85eb0dd chore: enforce explicit Buffer import and add lint rule (#6525)
Signed-off-by: Shivam Sharma <meshivam81@gmail.com>
2025-06-27 20:10:36 -05:00
kgarg1
b8ab46594d test: add coverage for app.listen() variants (#6476)
* test: add coverage for app.listen() variants

- verify alternate signatures (port+host+backlog)
- verify server.address() shape

* fix linter issue

---------

Co-authored-by: kuldeep <kuldeep@wanclouds.net>
2025-05-28 19:26:16 -05:00
Noritaka Kobayashi
dfd1851245 test: fix typos in test descriptions (#6535) 2025-05-27 10:36:50 +02:00
Jon Church
9f4dbe3a13 chore: wider range for query test skip (#6512) 2025-05-15 11:40:26 -05:00
dufucun
f9954dd317 fix(test): remove duplicate word (#6456)
Signed-off-by: dufucun <dufuchun@sohu.com>
2025-04-16 11:18:38 -05:00
Ashish Sharma
5da5a11a49 increased code coverage of utils.js file (#6386)
Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
2025-04-10 20:57:43 -05:00
Andrea Polverino
caa4f68ee8 feat: Extend res.links() to allow adding multiple links with the same rel (closes #2729) (#4885) 2025-02-14 10:20:53 -06:00
Juan José
327af123a1 feat: add support for ETag option in res.sendFile (#6073)
This patch introduces the ability to control the ETag generation
through the `res.sendFile` function. Specifically, the ETag option
is wired to the application's configuration, allowing it to be
enabled or disabled based on the app's settings.

Fixes: https://github.com/expressjs/express/issues/2294

Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com>
2025-02-13 13:39:31 -06:00
Alexander Cerutti
55869f49a6 feat: Added check to support Uint8Array in response sending (#6285)
Unified usage of ArrayBuffer.isView to comprehend Buffer and removed isView function check

Co-authored-by: Wes Todd <wes@wesleytodd.com>

Added Uint8Array test with encoding

fix: added history.md entry
2025-02-10 11:23:02 -06:00
Szymon Łągiewka
41113599af fix(refactor): prefix built-in node module imports
Since v5 relies on node >= 18, this is now possible (since v16, v14.18.0
[^1][^2]).

It's functionally irrelevant:
1. It's not required for CJS nor ESM (with a few exceptions [^3])
2. It has no performance promises

However, there are upsides to this approach:
1. It brings clear boundaries to what's a built-in and what's an
external dependency
2. It reduces the risk of importing unwanted deps where a built-in is
expected
3. It's slightly more interoperable with other JS runtimes that provide
node compatibility[^4], albeit only during development. Once imported
from npm, built-ins are assumed.

[^1]:https://nodejs.org/docs/latest-v22.x/api/modules.html#built-in-modules
[^2]:https://github.com/nodejs/node/pull/37246
[^3]:https://nodejs.org/api/modules.html#built-in-modules-with-mandatory-node-prefix
[^4]:https://docs.deno.com/runtime/fundamentals/node/#using-node's-built-in-modules
2025-01-10 11:53:44 -06:00
Phillip Barta
246f6f5aee fix: Remove utils-merge dependency - use spread syntax instead (#6091) 2025-01-08 09:56:16 -06:00
Jon Koops
b11122be85 chore: replace methods dependency with standard library (#6196) 2025-01-02 08:00:30 +01:00
Phillip Barta
4e92ac9031 cleanup: remove AsyncLocalStorage check from tests (#6147)
Co-authored-by: Wes Todd <wes@wesleytodd.com>
2024-11-15 10:23:42 -06:00
Phillip9587
9f8589e31c cleanup: remove unnecessary require for global Buffer
The Buffer object is globally available in Node.js, so there is no need to explicitly require it.
2024-11-15 10:16:29 -06:00
Phillip Barta
9e3dbb4374 chore(test): remove promise support check from tests (#6148)
Promises are supported in all supported Node.js version so the check is unnecessary
2024-11-12 09:30:34 -06:00
Bhavya Dhiman
c70197ad33 fix(buffer): use node:buffer instead of safe-buffer (#6071)
Main Changes:
- Removed dependency `safe-buffer@5.2.1`
- Use `node:buffer` core library instead of safe-buffer
2024-10-27 11:10:33 +01:00
Chris de Almeida
082d6d1253 test: add discarded middleware test (#5819) 2024-10-20 20:06:49 +02:00
Blake Embrey
bdd81f8670 Delete back as a magic string (#5933) 2024-09-09 20:28:55 -07:00
Wes Todd
f9256ef36f Merge branch '5.0' into 5-merge 2024-09-09 21:11:23 -05:00
Wes Todd
e5feb9fcc9 Merge tag '4.20.0' into 5.0 2024-09-09 21:07:57 -05:00
Ulises Gascón
4c9ddc1c47 feat: upgrade to serve-static@0.16.0 2024-09-10 04:01:43 +02:00
Ulises Gascón
ec4a01b6b8 feat: upgrade to body-parser@1.20.3 (#5926)
PR-URL: https://github.com/expressjs/express/pull/5926
2024-09-10 04:01:43 +02:00
Chris de Almeida
54271f69b5 fix: don't render redirect values in anchor href
Co-authored-by: Ulises Gascón <ulisesgascongonzalez@gmail.com>
2024-09-10 04:00:58 +02:00
Wes Todd
0264908903 feat(deps)!: router@^2.0.0 (#5885) 2024-09-09 17:50:11 -05:00
Jon Church
4d713d2b76 update to fresh@2.0.0 (#5916)
fixes handling of If-Modified-Since in combination with If-None-Match
2024-09-09 17:03:32 -05:00
Wes Todd
4e61d0100d fix(deps)!: mime-types@^3.0.0 (#5882) 2024-08-31 11:06:25 -05:00
Blake Embrey
c5addb9a17 deps: path-to-regexp@0.1.8 (#5603) 2024-08-21 20:15:02 -07:00
ctcpip
dde1f7d6e8 Merge branch '5.0' into 5-merge 2024-08-02 15:38:18 -05:00
Jon Church
82fc12a40b Ignore expires and maxAge in res.clearCookie() (#5792)
* add test for removing user provided expires

* rework impl and tests to ignore maxAge, do not set it

this is to take into account the built-in relative expires when passing
a maxAge to res.cookie

I realized that using maxAge to invalidate cookies inherrently hit this
relativee expires behavior, and the goal of this PR is not to rework
that relative expires behavior w/ maxAge, but to prevent users from
overwriting these values by accident when clearing cookies

* update history.md

* explicitly delete maxAge instead of setting as undefined

* drop the spread, use object.assign

* wording, review comment on history.md

Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>

* ♻️ use spread, update supported ecmascript version

---------

Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>
2024-08-02 15:26:45 -05:00
Jon Church
723b5451bb Throw on invalid status codes (#4212)
* check status code is integer, or string integer, in range

* fix tests, update jsdoc comment for res.status

* throw if number is string

* narrow valid range to between 1xx and 5xx

* disambiguate the error message

* update skipped tests, remove invalid string test

* remove invalid float test

* fixup! remove invalid float test

* fix invalid range tests error assertions

* remove unused deprecate function

* add test to assert on 200.00 coming through as 200

this is the behavior of node's underlying HTTP module

* revert back to throwing only on > 999 and < 100

* update implementation for > 999

* add test for 700 status code

* update history with change

* update jsdoc

* clarify jsdoc comment

* one more round of jsdoc

* update 501 test

* add invalid status code test for res.sendStatus

* add test describe block for valid range

* fixup! add test describe block for valid range

* reduce the describe nesting

* switch to testing status 100, to avoid 100-continue behavior

* fix 900 test

* stringify code in thrown RangeError message

* remove accidentally duplicated res.status method

* fix error range message

Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>

* update sendStatus invalid code test to use sendStatus

---------

Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>
2024-07-30 14:49:13 -07:00
ctcpip
c96c690dc0 Merge branch 'master' into 5.0 2024-07-25 16:55:48 -05:00
Jon Church
61421a8c0c skip QUERY tests for Node 21 only, still not supported (#5695)
* skip QUERY tests for Node 21 only, still not supported

QUERY support has now landed in Node 22.2.0, but is still not supported
in 21.7.3

QUERY showed up in http.METHODS in 21.7.2. Only Node versions after that
will attempt to run tests for it, based on the way we dynamically test
members of the http.METHODS array from Node

* update CI to run on 21.7 and 22.2
2024-06-08 23:25:42 -04:00
Jon Church
f42b160bbc [v4] Deprecate res.clearCookie accepting options.maxAge and options.expires (#5672)
* add deprecation notice for res.clearCookie maxAge/expires

* update History.md for clearCookie deprecation change

* add tests to codify deprecated behavior

Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>

---------

Co-authored-by: Chris de Almeida <ctcpip@users.noreply.github.com>
2024-06-07 19:48:48 -04:00
Chris de Almeida
689073d657 bring back query tests for node 21 (#5690) 2024-06-05 17:25:58 -04:00
Wes
ee40a881f5 call callback once on listen error 2024-05-17 13:47:56 -07:00
Jon Church
b44191eb3d ignore ETAG query test as well, reuse skip util (#5639) 2024-05-04 18:01:42 -04:00
Jon Church
8417c60fcf skip QUERY method test (#5628) 2024-05-04 17:09:52 -04:00
Blake Embrey
bf91946bd4 deps: encodeurl@~2.0.0 (#5569) 2024-05-04 16:53:09 -04:00
Evan Hahn
14439731f9 Use object with null prototype for various app properties
`app.cache`, `app.engines`, and `app.settings` are now created with
`Object.create(null)` instead of `{}`.

This also updates a test to ensure that `app.locals` is created the same
way.
2024-04-29 09:43:25 -05:00
Wes Todd
94669f9289 remove duplicate location test for data uri 2024-03-26 09:41:06 -05:00