fix price and modular

This commit is contained in:
2026-02-01 17:38:39 +03:30
parent 55f34aa15d
commit 164542d3e2
801 changed files with 16129 additions and 14478 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
import http from 'node:http';
import https from 'node:https';
import nodeFetch, { Headers as Headers$1, AbortController as AbortController$1 } from 'node-fetch-native';
import { c as createFetch } from './shared/ofetch.03887fc3.mjs';
export { F as FetchError, a as createFetchError } from './shared/ofetch.03887fc3.mjs';
import nodeFetch, { AbortController as AbortController$1, Headers as Headers$1 } from 'node-fetch-native';
import { c as createFetch } from './shared/ofetch.CWycOUEr.mjs';
export { F as FetchError, a as createFetchError } from './shared/ofetch.CWycOUEr.mjs';
import 'destr';
import 'ufo';
@@ -67,6 +67,9 @@ function isJSONSerializable(value) {
if (value.buffer) {
return false;
}
if (value instanceof FormData || value instanceof URLSearchParams) {
return false;
}
return value.constructor && value.constructor.name === "Object" || typeof value.toJSON === "function";
}
const textTypes = /* @__PURE__ */ new Set([
@@ -84,6 +87,9 @@ function detectResponseType(_contentType = "") {
if (JSON_RE.test(contentType)) {
return "json";
}
if (contentType === "text/event-stream") {
return "stream";
}
if (textTypes.has(contentType) || contentType.startsWith("text/")) {
return "text";
}
@@ -205,6 +211,12 @@ function createFetch(globalOptions = {}) {
}
if (context.options.onRequest) {
await callHooks(context, context.options.onRequest);
if (!(context.options.headers instanceof Headers)) {
context.options.headers = new Headers(
context.options.headers || {}
/* compat */
);
}
}
if (typeof context.request === "string") {
if (context.options.baseURL) {
@@ -223,9 +235,13 @@ function createFetch(globalOptions = {}) {
}
if (context.options.body && isPayloadMethod(context.options.method)) {
if (isJSONSerializable(context.options.body)) {
context.options.body = typeof context.options.body === "string" ? context.options.body : JSON.stringify(context.options.body);
context.options.headers = new Headers(context.options.headers || {});
if (!context.options.headers.has("content-type")) {
const contentType = context.options.headers.get("content-type");
if (typeof context.options.body !== "string") {
context.options.body = contentType === "application/x-www-form-urlencoded" ? new URLSearchParams(
context.options.body
).toString() : JSON.stringify(context.options.body);
}
if (!contentType) {
context.options.headers.set("content-type", "application/json");
}
if (!context.options.headers.has("accept")) {
+19 -19
View File
@@ -1,6 +1,6 @@
{
"name": "ofetch",
"version": "1.4.1",
"version": "1.5.1",
"description": "A better fetch API. Works on node, browser and workers.",
"repository": "unjs/ofetch",
"license": "MIT",
@@ -66,31 +66,31 @@
"lint:fix": "eslint --fix . && prettier -w src test playground examples",
"prepack": "pnpm build",
"play": "jiti playground/index.ts",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"release": "pnpm test && changelogen --release --publish",
"test": "pnpm lint && vitest run --coverage"
},
"dependencies": {
"destr": "^2.0.3",
"node-fetch-native": "^1.6.4",
"ufo": "^1.5.4"
"destr": "^2.0.5",
"node-fetch-native": "^1.6.7",
"ufo": "^1.6.1"
},
"devDependencies": {
"@types/node": "^22.7.5",
"@vitest/coverage-v8": "^2.1.2",
"changelogen": "^0.5.7",
"eslint": "^9.12.0",
"eslint-config-unjs": "^0.4.1",
"@types/node": "^24.9.1",
"@vitest/coverage-v8": "^4.0.4",
"changelogen": "^0.6.2",
"eslint": "^9.38.0",
"eslint-config-unjs": "^0.5.0",
"fetch-blob": "^4.0.0",
"formdata-polyfill": "^4.0.10",
"h3": "^1.13.0",
"jiti": "^2.3.3",
"h3": "^1.15.4",
"jiti": "^2.6.1",
"listhen": "^1.9.0",
"prettier": "^3.3.3",
"std-env": "^3.7.0",
"typescript": "^5.6.2",
"unbuild": "^2.0.0",
"undici": "^6.19.8",
"vitest": "^2.1.2"
"prettier": "^3.6.2",
"std-env": "^3.10.0",
"typescript": "^5.9.3",
"unbuild": "^3.6.1",
"undici": "^7.16.0",
"vitest": "^4.0.4"
},
"packageManager": "pnpm@9.12.1"
"packageManager": "pnpm@10.19.0"
}