html-get 2.26.8 → 2.26.9
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 +1 -1
- package/src/index.js +9 -0
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.26.
|
|
5
|
+
"version": "2.26.9",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"bin": {
|
package/src/index.js
CHANGED
|
@@ -185,6 +185,15 @@ const prerender = PCancelable.fn(
|
|
|
185
185
|
)
|
|
186
186
|
|
|
187
187
|
const payload = await getPayload(url, opts)
|
|
188
|
+
// page.content() succeeds on 4xx/5xx challenge pages; only cancel
|
|
189
|
+
// fetch when prerender is actually usable, otherwise keep a 2xx/3xx fetch.
|
|
190
|
+
if (payload.statusCode >= 400) {
|
|
191
|
+
const { isRejected, ...dataProps } = await fetchRes
|
|
192
|
+
if (!isRejected && dataProps.statusCode < 400) {
|
|
193
|
+
debug('prerender', { url, state: 'fallback', statusCode: payload.statusCode })
|
|
194
|
+
return dataProps
|
|
195
|
+
}
|
|
196
|
+
}
|
|
188
197
|
await fetchRes.cancel()
|
|
189
198
|
debug('prerender', { url, state: 'success' })
|
|
190
199
|
return payload
|