Visitar URL original
chore: remove mocha and chai by Uzlopak · Pull Request #2696 · nodejs/undici · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: remove mocha and chai, fix bug in fetch request
  • Loading branch information
Uzlopak committed Feb 5, 2024
commit a182b9f03f0cab4395bf462552c1fb5ce8c93e1c
50 changes: 48 additions & 2 deletions lib/fetch/request.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* globals AbortController */

'use strict'

const { extractBody, mixinBody, cloneBody } = require('./body')
const { Headers, fill: fillHeaders, HeadersList } = require('./headers')
const { FinalizationRegistry } = require('../compat/dispatcher-weakref')()
const util = require('../core/util')
const { types } = require('node:util')
const {
isBlobLike
} = require('./util')
const {
isValidHTTPToken,
sameOrigin,
Expand Down Expand Up @@ -887,6 +889,50 @@ webidl.converters.Request = webidl.interfaceConverter(
Request
)

webidl.converters.FormData = webidl.interfaceConverter(
FormData
)

// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
webidl.converters.XMLHttpRequestBodyInit = function (V) {
if (typeof V === 'string') {
return webidl.converters.USVString(V)
}

if (isBlobLike(V)) {
return webidl.converters.Blob(V, { strict: false })
}

if (ArrayBuffer.isView(V) || types.isArrayBuffer(V)) {
return webidl.converters.BufferSource(V)
}

if (util.isFormDataLike(V)) {
return webidl.converters.FormData(V, { strict: false })
}

if (V instanceof URLSearchParams) {
return webidl.converters.URLSearchParams(V)
}

return webidl.converters.DOMString(V)
}

// https://fetch.spec.whatwg.org/#bodyinit
webidl.converters.BodyInit = function (V) {
if (V instanceof ReadableStream) {
return webidl.converters.ReadableStream(V)
}

// Note: the spec doesn't include async iterables,
// this is an undici extension.
if (V?.[Symbol.asyncIterator]) {
return V
}

return webidl.converters.XMLHttpRequestBodyInit(V)
}

Comment thread
Uzlopak marked this conversation as resolved.
Resolved
// https://fetch.spec.whatwg.org/#requestinfo
webidl.converters.RequestInfo = function (V) {
if (typeof V === 'string') {
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"lint:fix": "standard --fix | snazzy",
"test": "node scripts/generate-pem && npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:eventsource && npm run test:wpt && npm run test:websocket && npm run test:jest && npm run test:typescript && npm run test:node-test",
"test:cookies": "borp --coverage -p \"test/cookie/*.js\"",
"test:node-fetch": "mocha --exit test/node-fetch",
"test:node-fetch": "borp --coverage -p \"test/node-fetch/**/*.js\"",
"test:eventsource": "npm run build:node && borp --expose-gc --coverage -p \"test/eventsource/*.js\"",
"test:fetch": "npm run build:node && borp --expose-gc --coverage -p \"test/fetch/*.js\" && borp --coverage -p \"test/webidl/*.js\"",
"test:jest": "jest",
Expand All @@ -105,10 +105,6 @@
"@types/node": "^18.0.3",
"abort-controller": "^3.0.0",
"borp": "^0.5.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-iterator": "^3.0.2",
"chai-string": "^1.5.0",
"concurrently": "^8.0.1",
"cronometro": "^2.0.2",
"dns-packet": "^5.4.0",
Expand All @@ -122,7 +118,6 @@
"jsdom": "^24.0.0",
"jsfuzz": "^1.0.15",
"mitata": "^0.1.8",
"mocha": "^10.0.0",
"p-timeout": "^3.2.0",
"pre-commit": "^1.2.2",
"proxy": "^1.0.2",
Expand All @@ -145,7 +140,7 @@
},
"standard": {
"env": [
"mocha"
"jest"
],
"ignore": [
"lib/llhttp/constants.js",
Expand Down
Loading