Commit Graph

416 Commits

Author SHA1 Message Date
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
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
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
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
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
Carlos Serrano
09831580ec
refactor: replace 'path-is-absolute' dep with node:path isAbsolute method (#5830)
* refactor: replace 'path-is-absolute' dep with node:path isAbsolute method

* docs: add path-is-absolute dep removal to History.md
2024-08-17 10:21:29 -05: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
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
Blake Embrey
bf91946bd4
deps: encodeurl@~2.0.0 (#5569) 2024-05-04 16:53:09 -04:00
Wes Todd
6415f7035b Merge tag '4.19.2' into 5.0
4.19.2
2024-03-25 09:37:02 -05:00
Wes Todd
0b746953c4 Improved fix for open redirect allow list bypass
Co-authored-by: Jon Church <me@jonchurch.com>
Co-authored-by: Blake Embrey <hello@blakeembrey.com>
2024-03-25 09:29:41 -05:00
Wes Todd
da4d763ff6 Improved fix for open redirect allow list bypass
Co-authored-by: Jon Church <me@jonchurch.com>
Co-authored-by: Blake Embrey <hello@blakeembrey.com>
2024-03-25 09:22:34 -05:00
Wes Todd
60fb1d2acd Merge tag '4.19.1' into 5.x
4.19.1
2024-03-20 21:17:26 -05:00
Wes Todd
e9f9aaeebd Merge tag '4.19.0' into 5.x
4.19.0
2024-03-20 21:14:00 -05:00
Wes Todd
a003cfab03 Allow passing non-strings to res.location with new encoding handling checks fixes #5554 #5555 2024-03-20 17:12:46 -05:00
FDrag0n
0867302ddb Prevent open redirect allow list bypass due to encodeurl
Co-authored-by: Jon Church <me@jonchurch.com>
2024-03-20 10:18:54 -05:00
3imed-jaberi
980d881e3b deps: statuses@2.0.1
closes #4336
2022-04-02 22:39:35 -04:00
Douglas Christopher Wilson
a10770286e Use http-errors for res.format error 2022-03-27 23:41:31 -04:00
Chris Barth
5855339455 Fix behavior of null/undefined as "maxAge" in res.cookie
fixes #3935
closes #3936
2022-03-26 23:11:48 -04:00
Nadav Ivgi
9482b82d0b Invoke default with same arguments as types in res.format
closes #3587
2022-03-26 01:29:40 -04:00
Douglas Christopher Wilson
03dc367187 Allow options without filename in res.download 2022-03-25 18:13:42 -04:00
Tommaso Tofacchi
0def9bb659 Add "root" option to res.download
fixes #4834
closes #4855
2022-03-25 00:08:38 -04:00
Jon Church
4847d0efa1 Deprecate string and non-integer arguments to res.status
closes #4223
2022-03-23 23:14:08 -04:00
Tito D. Kesumo Siregar
87279c08aa Support proper 205 responses using res.send
closes #4592
closes #4596
2022-03-23 20:05:05 -04:00
apeltop
d0e166c3c6 docs: fix typo in private api jsdoc
closes #4843
2022-02-28 18:37:41 -05:00
Douglas Christopher Wilson
318fd4b543 Merge tag '4.17.3' 2022-02-17 00:27:11 -05:00
Douglas Christopher Wilson
a0276c6c91 Use mime-types for file to content type mapping 2022-02-06 10:26:18 -05:00
caioagiani
89bb531b31 docs: fix typo in res.download jsdoc
closes #4805
2022-02-03 23:26:17 -05:00
Douglas Christopher Wilson
c7d528cdc0 Merge tag '4.17.2' 2021-12-16 23:01:28 -05:00
drewm
f275e87dff Fix handling of undefined when "json escape" is enabled
closes #4744
2021-11-17 00:00:56 -05:00
Douglas Christopher Wilson
9dd0e7afdb Fix handling of undefined in res.jsonp 2021-11-16 23:58:17 -05:00
Kim
a1dbb11377 Fix res.jsonp(obj, status) deprecation message
closes #4155
2021-11-16 00:41:19 -05:00
Douglas Christopher Wilson
de081eb70f build: eslint@4.19.1 2021-09-01 19:27:00 -04:00
zhangky
f9a0560a9c docs: fix res.sendStatus/sendFile jsdoc comments
closes #4673
2021-08-14 00:39:56 -04:00
Hussein Mohamed
135a05c524 docs: fix typos in jsdoc
closes #4564
2021-07-31 16:00:00 -04:00
Douglas Christopher Wilson
121fe9982b Merge tag '4.17.1' 2019-06-08 19:43:21 -04:00
Douglas Christopher Wilson
0a48e18056 Revert "Improve error message for null/undefined to res.status"
fixes #3968
2019-05-25 18:15:13 -04:00
Douglas Christopher Wilson
b8e50568af tests: ignore unreachable line 2019-05-16 10:04:24 -04:00
Louis
6f12eee8ab docs: fix typo in jsdoc comment
closes #3859
2019-04-16 10:29:07 -04:00
Joshua Caron
8da51108e7 Improve error message for null/undefined to res.status
closes #2795
closes #2797
closes #3111
2018-10-27 14:04:49 -04:00
void
6bcdfef6ad Improve error message for non-strings to res.sendFile
closes #3582
2018-10-27 02:27:15 -04:00
Douglas Christopher Wilson
3d10279826 Fix issue where "Request aborted" may be logged in res.sendfile 2018-09-19 23:25:16 -04:00
Douglas Christopher Wilson
62e12fe710 Merge tag '4.16.2' 2017-10-13 22:27:30 -04:00
David Wood
b7817ab1b0 Fix TypeError in res.send when given Buffer and ETag header set
fixes #3445
2017-10-09 22:11:49 -04:00