html-get 2.27.0 → 2.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/util.js +4 -10
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "html-get",
|
|
3
3
|
"description": "Get the HTML from any website, fine-tuned for correction & speed",
|
|
4
4
|
"homepage": "https://nicedoc.com/microlinkhq/html-get",
|
|
5
|
-
"version": "2.27.
|
|
5
|
+
"version": "2.27.1",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"bin": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@kikobeats/time-span": "~1.0.13",
|
|
49
49
|
"@metascraper/helpers": "~5.56.2",
|
|
50
50
|
"cheerio": "~1.2.0",
|
|
51
|
-
"content-type": "~
|
|
51
|
+
"content-type": "~3.0.0",
|
|
52
52
|
"css-url-regex": "~4.0.0",
|
|
53
53
|
"debug-logfmt": "~1.4.12",
|
|
54
54
|
"execall": "~2.0.0",
|
package/src/util.js
CHANGED
|
@@ -11,24 +11,18 @@ const SEPARATOR = /,|\r?\n/
|
|
|
11
11
|
|
|
12
12
|
const parseContentType = contentType => {
|
|
13
13
|
if (typeof contentType !== 'string') return UNKNOWN_CONTENT_TYPE
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} catch {
|
|
17
|
-
return UNKNOWN_CONTENT_TYPE
|
|
18
|
-
}
|
|
14
|
+
const parsed = parse(contentType.split(SEPARATOR)[0])
|
|
15
|
+
return parsed.type?.includes('/') ? parsed : UNKNOWN_CONTENT_TYPE
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
const contentType = headers => {
|
|
22
19
|
const contentType = headers['content-type']
|
|
23
|
-
return (
|
|
24
|
-
CACHE[contentType] || (CACHE[contentType] = parseContentType(contentType))
|
|
25
|
-
)
|
|
20
|
+
return CACHE[contentType] || (CACHE[contentType] = parseContentType(contentType))
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
const getContentType = headers => contentType(headers).type
|
|
29
24
|
|
|
30
|
-
const getCharset = headers =>
|
|
31
|
-
contentType(headers).parameters.charset?.toLowerCase()
|
|
25
|
+
const getCharset = headers => contentType(headers).parameters.charset?.toLowerCase()
|
|
32
26
|
|
|
33
27
|
const getContentLength = headers => Number(headers['content-length'])
|
|
34
28
|
|