Comparing version 5.15.1 to 5.15.2
10
index.js
@@ -27,2 +27,10 @@ 'use strict' | ||
let hasCrypto | ||
try { | ||
require('crypto') | ||
hasCrypto = true | ||
} catch { | ||
hasCrypto = false | ||
} | ||
Object.assign(Dispatcher.prototype, api) | ||
@@ -132,3 +140,3 @@ | ||
if (nodeMajor >= 18) { | ||
if (nodeMajor >= 18 && hasCrypto) { | ||
const { WebSocket } = require('./lib/websocket/websocket') | ||
@@ -135,0 +143,0 @@ |
@@ -1077,4 +1077,2 @@ 'use strict' | ||
client[kSocket] = socket | ||
socket[kNoRef] = false | ||
@@ -1095,2 +1093,4 @@ socket[kWriting] = false | ||
client[kSocket] = socket | ||
if (channels.connected.hasSubscribers) { | ||
@@ -1181,3 +1181,3 @@ channels.connected.publish({ | ||
if (socket) { | ||
if (socket && !socket.destroyed) { | ||
if (client[kSize] === 0) { | ||
@@ -1249,3 +1249,3 @@ if (!socket[kNoRef] && socket.unref) { | ||
connect(client) | ||
continue | ||
return | ||
} | ||
@@ -1252,0 +1252,0 @@ |
@@ -357,4 +357,19 @@ 'use strict' | ||
// The chunk should be a FormData instance and contains | ||
// all the required methods. | ||
function isFormDataLike (chunk) { | ||
return chunk && chunk.constructor && chunk.constructor.name === 'FormData' | ||
return (chunk && | ||
chunk.constructor && chunk.constructor.name === 'FormData' && | ||
typeof chunk === 'object' && | ||
(typeof chunk.append === 'function' && | ||
typeof chunk.delete === 'function' && | ||
typeof chunk.get === 'function' && | ||
typeof chunk.getAll === 'function' && | ||
typeof chunk.has === 'function' && | ||
typeof chunk.set === 'function' && | ||
typeof chunk.entries === 'function' && | ||
typeof chunk.keys === 'function' && | ||
typeof chunk.values === 'function' && | ||
typeof chunk.forEach === 'function') | ||
) | ||
} | ||
@@ -361,0 +376,0 @@ |
@@ -8,2 +8,8 @@ const assert = require('assert') | ||
// Regex | ||
const HTTP_TOKEN_CODEPOINTS = /^[!#$%&'*+-.^_|~A-z0-9]+$/ | ||
const HTTP_WHITESPACE_REGEX = /(\u000A|\u000D|\u0009|\u0020)/ // eslint-disable-line | ||
// https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point | ||
const HTTP_QUOTED_STRING_TOKENS = /^(\u0009|\x{0020}-\x{007E}|\x{0080}-\x{00FF})+$/ // eslint-disable-line | ||
// https://fetch.spec.whatwg.org/#data-url-processor | ||
@@ -221,3 +227,3 @@ /** @param {URL} dataURL */ | ||
// https://mimesniff.spec.whatwg.org/#http-token-code-point | ||
if (type.length === 0 || !/^[!#$%&'*+-.^_|~A-z0-9]+$/.test(type)) { | ||
if (type.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(type)) { | ||
return 'failure' | ||
@@ -249,3 +255,3 @@ } | ||
// contain HTTP token code points, then return failure. | ||
if (subtype.length === 0 || !/^[!#$%&'*+-.^_|~A-z0-9]+$/.test(subtype)) { | ||
if (subtype.length === 0 || !HTTP_TOKEN_CODEPOINTS.test(subtype)) { | ||
return 'failure' | ||
@@ -264,5 +270,3 @@ } | ||
// https://mimesniff.spec.whatwg.org/#mime-type-essence | ||
get essence () { | ||
return `${this.type}/${this.subtype}` | ||
} | ||
essence: `${type}/${subtype}` | ||
} | ||
@@ -279,3 +283,3 @@ | ||
// https://fetch.spec.whatwg.org/#http-whitespace | ||
(char) => /(\u000A|\u000D|\u0009|\u0020)/.test(char), // eslint-disable-line | ||
char => HTTP_WHITESPACE_REGEX.test(char), | ||
input, | ||
@@ -363,5 +367,4 @@ position | ||
parameterName.length !== 0 && | ||
/^[!#$%&'*+-.^_|~A-z0-9]+$/.test(parameterName) && | ||
// https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point | ||
!/^(\u0009|\x{0020}-\x{007E}|\x{0080}-\x{00FF})+$/.test(parameterValue) && // eslint-disable-line | ||
HTTP_TOKEN_CODEPOINTS.test(parameterName) && | ||
!HTTP_QUOTED_STRING_TOKENS.test(parameterValue) && | ||
!mimeType.parameters.has(parameterName) | ||
@@ -368,0 +371,0 @@ ) { |
'use strict' | ||
// TODO: crypto isn't available in all environments | ||
const { randomBytes, createHash } = require('crypto') | ||
@@ -5,0 +4,0 @@ const diagnosticsChannel = require('diagnostics_channel') |
{ | ||
"name": "undici", | ||
"version": "5.15.1", | ||
"version": "5.15.2", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -82,2 +82,3 @@ "homepage": "https://undici.nodejs.org", | ||
"docsify-cli": "^4.4.3", | ||
"form-data": "^4.0.0", | ||
"formdata-node": "^4.3.1", | ||
@@ -84,0 +85,0 @@ "https-pem": "^3.0.0", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1069418
17911
34