Skip to content

Commit 36a53bb

Browse files
committed
chore: Update deps and metadata
Signed-off-by: Richie Bendall <[email protected]>
1 parent caa738c commit 36a53bb

File tree

4 files changed

+165
-197
lines changed

4 files changed

+165
-197
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 - 1019 The Node Fetch Team
3+
Copyright (c) 2019 Richie Bendall and 2016 - 1019 The Node Fetch Team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@types/cheerio": "^0.22.13",
3434
"@types/content-type": "^1.1.3",
3535
"eslint": "^6.6.0",
36-
"eslint-config-richienb": "^0.2.0",
36+
"eslint-config-richienb": "^0.2.2",
3737
"microbundle": "^0.11.0",
3838
"typedoc": "^0.15.0"
3939
},

src/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* MIT License
55
*
6-
* Copyright (c) 2016 - 2019 The Node Fetch Team
6+
* Copyright (c) 2019 Richie Bendall and 2016 - 2019 The Node Fetch Team
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the 'Software'), to deal
@@ -26,7 +26,7 @@
2626

2727
import { decode as convert } from "iconv-lite"
2828
import getCharSet from "./utils/getCharSet"
29-
import { parse as $ } from "cheerio"
29+
import { load as $ } from "cheerio"
3030
import { isURLSearchParams, isBlob, isArrayBuffer } from "./utils/is"
3131
import { Stream, Writable } from "stream"
3232

@@ -48,11 +48,13 @@ export function convertBody(buffer: Buffer, headers?: Headers): string {
4848
const res = buffer.slice(0, 1024).toString()
4949

5050
// HTML5, HTML4 and XML
51-
if (!charset && res) charset = getCharSet(
52-
$(res)("meta[charset]").attr("charset") || // HTML5
53-
$(res)("meta[http-equiv][content]").attr("content") || // HTML4
54-
$(res.replace(/<\?(.*)\?>/im, "<$1>"), { xmlMode: true }).root().find("xml").attr("encoding") // XML
55-
)
51+
if (!charset && res) {
52+
charset = getCharSet(
53+
$(res)("meta[charset]").attr("charset") || // HTML5
54+
$(res)("meta[http-equiv][content]").attr("content") || // HTML4
55+
$(res.replace(/<\?(.*)\?>/im, "<$1>"), { xmlMode: true }).root().find("xml").attr("encoding") // XML
56+
)
57+
}
5658

5759
// Prevent decode issues when sites use incorrect encoding
5860
// ref: https://hsivonen.fi/encoding-menu/

0 commit comments

Comments
 (0)