New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/fetch

Package Overview
Dependencies
Maintainers
1
Versions
530
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/fetch - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1-alpha-20221028013012-a9e07ae

6

CHANGELOG.md
# @whatwg-node/fetch
## 0.5.1-alpha-20221028013012-a9e07ae
### Patch Changes
- [`a8a7cfc`](https://github.com/ardatan/whatwg-node/commit/a8a7cfcbb98c5ca8fff3b4a6d8638e9208690b61) Thanks [@ardatan](https://github.com/ardatan)! - Fix for new undici
## 0.5.0

@@ -4,0 +10,0 @@

@@ -125,2 +125,5 @@ const handleFileRequest = require("./handle-file-request");

if (typeof requestOrUrl === "string" || requestOrUrl instanceof URL) {
if (options != null && typeof options === "object" && !options.duplex) {
options.duplex = 'half';
}
super(requestOrUrl, options);

@@ -144,2 +147,5 @@ const contentType = this.headers.get("content-type");

if (typeof requestOrUrl === "string" || requestOrUrl instanceof URL) {
if (options != null && typeof options === "object" && !options.duplex) {
options.duplex = 'half';
}
// We cannot use our ctor because it leaks on Node 18's global fetch

@@ -146,0 +152,0 @@ return originalFetch(requestOrUrl, options);

4

package.json
{
"name": "@whatwg-node/fetch",
"version": "0.5.0",
"version": "0.5.1-alpha-20221028013012-a9e07ae",
"description": "Cross Platform Smart Fetch Ponyfill",

@@ -27,3 +27,3 @@ "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",

"node-fetch": "^2.6.7",
"undici": "^5.10.0",
"undici": "^5.12.0",
"web-streams-polyfill": "^3.2.0"

@@ -30,0 +30,0 @@ },

import { createTestContainer } from '../../server/test/create-test-container';
describe('getFormDataMethod', () => {
createTestContainer(
fetchAPI => {
it('should parse fields correctly', async () => {
const formData = new fetchAPI.FormData();
formData.append('greetings', 'Hello world!');
formData.append('bye', 'Goodbye world!');
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
const formdata = await request.formData();
expect(formdata.get('greetings')).toBe('Hello world!');
expect(formdata.get('bye')).toBe('Goodbye world!');
createTestContainer(fetchAPI => {
it('should parse fields correctly', async () => {
const formData = new fetchAPI.FormData();
formData.append('greetings', 'Hello world!');
formData.append('bye', 'Goodbye world!');
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
it('should parse and receive text files correctly', async () => {
const formData = new fetchAPI.FormData();
const greetingsFile = new fetchAPI.File(['Hello world!'], 'greetings.txt', { type: 'text/plain' });
const byeFile = new fetchAPI.File(['Goodbye world!'], 'bye.txt', { type: 'text/plain' });
formData.append('greetings', greetingsFile);
formData.append('bye', byeFile);
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
const formdata = await request.formData();
const receivedGreetingsFile = formdata.get('greetings') as File;
const receivedGreetingsText = await receivedGreetingsFile.text();
expect(receivedGreetingsText).toBe('Hello world!');
const receivedByeFile = formdata.get('bye') as File;
const receivedByeText = await receivedByeFile.text();
expect(receivedByeText).toBe('Goodbye world!');
const formdata = await request.formData();
expect(formdata.get('greetings')).toBe('Hello world!');
expect(formdata.get('bye')).toBe('Goodbye world!');
});
it('should parse and receive text files correctly', async () => {
const formData = new fetchAPI.FormData();
const greetingsFile = new fetchAPI.File(['Hello world!'], 'greetings.txt', { type: 'text/plain' });
const byeFile = new fetchAPI.File(['Goodbye world!'], 'bye.txt', { type: 'text/plain' });
formData.append('greetings', greetingsFile);
formData.append('bye', byeFile);
const request = new fetchAPI.Request('http://localhost:8080', {
method: 'POST',
body: formData,
});
}
);
const formdata = await request.formData();
const receivedGreetingsFile = formdata.get('greetings') as File;
const receivedGreetingsText = await receivedGreetingsFile.text();
expect(receivedGreetingsText).toBe('Hello world!');
const receivedByeFile = formdata.get('bye') as File;
const receivedByeText = await receivedByeFile.text();
expect(receivedByeText).toBe('Goodbye world!');
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc