mirror of
https://github.com/cheeriojs/cheerio.git
synced 2026-02-25 23:25:17 +00:00
chore: Bump deps, remove undici interceptor
* build(deps-dev): bump vitest from 2.1.8 to 3.1.4 Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 2.1.8 to 3.1.4. - [Release notes](https://github.com/vitest-dev/vitest/releases) - [Commits](https://github.com/vitest-dev/vitest/commits/v3.1.4/packages/vitest) --- updated-dependencies: - dependency-name: vitest dependency-version: 3.1.4 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * bump * undici? * no mo interceptor --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Felix <188768+fb55@users.noreply.github.com>
This commit is contained in:
1324
package-lock.json
generated
1324
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -125,7 +125,7 @@
|
||||
"parse5": "^7.3.0",
|
||||
"parse5-htmlparser2-tree-adapter": "^7.1.0",
|
||||
"parse5-parser-stream": "^7.1.2",
|
||||
"undici": "^7.8.0",
|
||||
"undici": "^7.10.0",
|
||||
"whatwg-mimetype": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -136,7 +136,7 @@
|
||||
"@types/whatwg-mimetype": "^3.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||
"@typescript-eslint/parser": "^8.31.1",
|
||||
"@vitest/coverage-v8": "^2.1.8",
|
||||
"@vitest/coverage-v8": "^3.1.4",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^10.1.2",
|
||||
"eslint-plugin-jsdoc": "^50.6.11",
|
||||
@@ -153,7 +153,7 @@
|
||||
"tshy": "^3.0.2",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^2.1.8"
|
||||
"vitest": "^3.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.17"
|
||||
|
||||
17
src/index.ts
17
src/index.ts
@@ -215,12 +215,7 @@ export async function fromURL(
|
||||
options: CheerioRequestOptions = {},
|
||||
): Promise<CheerioAPI> {
|
||||
const {
|
||||
requestOptions = {
|
||||
...defaultRequestOptions,
|
||||
dispatcher: undici
|
||||
.getGlobalDispatcher()
|
||||
.compose(undici.interceptors.responseError()),
|
||||
},
|
||||
requestOptions = defaultRequestOptions,
|
||||
encoding = {},
|
||||
...cheerioOptions
|
||||
} = options;
|
||||
@@ -231,6 +226,16 @@ export async function fromURL(
|
||||
|
||||
const promise = new Promise<CheerioAPI>((resolve, reject) => {
|
||||
undiciStream = undici.stream(url, requestOptions, (res) => {
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw new undici.errors.ResponseError(
|
||||
'Response Error',
|
||||
res.statusCode,
|
||||
{
|
||||
headers: res.headers,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
const contentTypeHeader = res.headers['content-type'] ?? 'text/html';
|
||||
const mimeType = new MIMEType(
|
||||
Array.isArray(contentTypeHeader)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
/* Basic Options */
|
||||
"target": "es2019",
|
||||
"module": "node16",
|
||||
"moduleResolution": "node16",
|
||||
"lib": ["ES2015.Core"],
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
|
||||
Reference in New Issue
Block a user