f0390fb7ed
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 <[email protected] >
2026-01-31 21:53:38 -05:00
ea56b3504b
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 <[email protected] >
Co-authored-by: Sebastian Beltran <[email protected] >
2026-01-16 21:27:22 -05:00
Shivam Sharma and GitHub
e270ec050a
chore: enforce explicit Buffer import and add lint rule ( #6525 )
...
Signed-off-by: Shivam Sharma <[email protected] >
2025-06-27 20:10:36 -05:00
6506d31ced
increased code coverage of utils.js file ( #6386 )
...
Co-authored-by: Sebastian Beltran <[email protected] >
2025-04-10 20:57:43 -05:00
Szymon Łągiewka and Wes Todd
4199d3218f
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
Phillip9587 and Wes Todd
b748a0d705
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 and GitHub
72e2b8aed2
fix(buffer): use node:buffer instead of safe-buffer ( #6071 )
...
Main Changes:
- Removed dependency `[email protected] `
- Use `node:buffer` core library instead of safe-buffer
2024-10-27 11:10:33 +01:00
Douglas Christopher Wilson
318fd4b543
Merge tag '4.17.3'
2022-02-17 00:27:11 -05:00
Douglas Christopher Wilson
a65913776d
tests: use strict mode
2022-02-09 01:07:08 -05:00
Douglas Christopher Wilson
bd4fdfe5f7
tests: remove global dependency on should
...
fixes #4797
2022-02-02 01:55:16 -05:00
Douglas Christopher Wilson
62e12fe710
Merge tag '4.16.2'
2017-10-13 22:27:30 -04:00
Douglas Christopher Wilson
12c3712468
Use safe-buffer for improved Buffer API
2017-09-28 08:26:39 -04:00
Douglas Christopher Wilson
501e24e0a9
Merge tag '4.15.0'
2017-03-01 18:17:04 -05:00
Douglas Christopher Wilson
9f4dbae083
deps: etag@~1.8.0
2017-02-20 21:25:26 -05:00
huaoguo and Douglas Christopher Wilson
2e1284beb6
Fix Windows absolute path check using forward slashes
...
closes #3017
2016-06-01 16:47:03 -04:00
Jeremiah Senkpiel and Douglas Christopher Wilson
694869d2aa
Use path-is-absolute module for absolute path detection
...
closes #2620
2015-07-06 23:55:17 -04:00
Douglas Christopher Wilson
6c751191dd
Remove utils.flatten
2015-07-06 21:12:44 -04:00
Douglas Christopher Wilson
3d2ecdd5fa
Merge tag '3.21.0'
2015-06-18 22:10:21 -04:00
Douglas Christopher Wilson
c8d61b6269
deps: etag@~1.7.0
...
fixes #2667
2015-06-18 20:54:26 -04:00
Douglas Christopher Wilson
53e5991dd1
tests: add extra setCharset tests
2015-02-18 22:57:50 -05:00
Douglas Christopher Wilson
4d1ee23f84
Use etag module to generate ETag headers
2014-10-18 00:53:17 -04:00
Douglas Christopher Wilson
51d33edb79
Use etag to generate ETag headers
2014-09-09 00:13:49 -04:00
Douglas Christopher Wilson
3ffceff3ed
Merge tag '3.12.0'
2014-06-22 11:42:15 -04:00
Douglas Christopher Wilson
9c731f1883
deprecate things with depd module
2014-06-19 23:34:58 -04:00
Douglas Christopher Wilson
f433b7c7cf
replace utils.escape with html-escape
2014-06-03 00:37:32 -04:00
Douglas Christopher Wilson
db4448dda8
Merge tag '3.9.0'
2014-05-30 22:17:51 -04:00
Douglas Christopher Wilson
8751d7ecf8
tests: add more tests
2014-05-30 21:28:48 -04:00
Douglas Christopher Wilson
c21226aa7c
improve etag control for res.send
...
closes #1435
closes #2129
2014-05-30 21:02:21 -04:00
Douglas Christopher Wilson
3e358458f4
tests: add more etag tests
2014-05-30 19:51:32 -04:00
Douglas Christopher Wilson
8ab96ab80d
mark res.send ETag as weak and reduce collisions
2014-05-29 23:14:21 -04:00
Douglas Christopher Wilson
e7ad49bbbe
tests: add accepts test with params
2014-05-28 00:30:29 -04:00
Roman Shtylman
63c6a9c5ad
use escape-html module to escape html
...
Another util bites the dust.
2014-01-24 19:21:21 -05:00
Jonathan Ong
cec0c06a70
refactor req.is and req.accepts*
2014-01-03 02:50:09 -08:00
TJ Holowaychuk
99bc628ad1
fix long list params test
2013-04-13 09:07:48 -07:00
silentjohnny
88273a59f8
Added originalIndex to parseQuality to correctly sort long lists (v8 does unstable quicksort for length > 10)
2013-04-13 12:36:35 +02:00
Pavel Brylov and TJ Holowaychuk
9e684d45bc
add support for custom Accept parameters
2013-04-11 08:34:10 -07:00
Alexander Pirsig
18a3cc03ee
use buffer-crc32 module for ETag CRC generator
2012-11-21 12:44:07 +01:00
TJ Holowaychuk
d6d16b7899
Added req.accepts() comma-delimited string support
2012-03-24 11:36:52 -07:00
TJ Holowaychuk
86a9e0803a
refactored utils.accepts()
2012-03-24 11:32:28 -07:00
TJ Holowaychuk
6dac874ff4
renamed Router#_route() -> route()
2011-12-28 11:55:11 -07:00
TJ Holowaychuk
e44c874cab
Fixed parseQuality(), exclude q=0
2011-11-20 12:54:48 -08:00
TJ Holowaychuk
36be2b0688
Added utils.accepts(type, str)
2011-11-20 12:41:12 -08:00
TJ Holowaychuk
a8fd8cb645
Added req.accepted
2011-11-19 22:08:26 -08:00
TJ Holowaychuk
fd06084106
more tests
2011-11-19 21:49:20 -08:00
TJ Holowaychuk
285500488d
Added parseAccepts() util
2011-11-19 21:47:22 -08:00
TJ Holowaychuk
29d4ffd089
renamed prev util to parseQuality()
2011-11-19 21:43:48 -08:00
TJ Holowaychuk
fe5efa597b
Added utils.parseAccepts(str)
2011-11-19 21:40:12 -08:00
Tj Holowaychuk
ce2ec94e96
Added utils.escape(html) test
2011-11-11 14:29:23 -08:00
Tj Holowaychuk
d56e5d6923
Added utils.flatten(arr) tests
2011-11-11 14:27:36 -08:00
Tj Holowaychuk
5221ecc055
utils.isAbsolute() tests
2011-11-11 14:26:43 -08:00