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>
* 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>
* 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>
* 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>
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>
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
* 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>
* 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>
* 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
* 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>
`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.