relocate redirection loop error throw
This commit is contained in:
parent
b1d4978024
commit
3b04a27f0e
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@squeebot/core",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.1",
|
||||
"description": "Squeebot v3 core for the execution environment",
|
||||
"main": "lib/index.js",
|
||||
"module": "lib/",
|
||||
|
@ -10,9 +10,6 @@ export function httpGET(
|
||||
restrictToText = true,
|
||||
saveTo?: string,
|
||||
lback?: number): Promise<any> {
|
||||
if (lback && lback >= 4) {
|
||||
throw new Error('infinite loop!');
|
||||
}
|
||||
|
||||
const parsed = url.parse(link);
|
||||
const opts = {
|
||||
@ -35,6 +32,10 @@ export function httpGET(
|
||||
|
||||
const httpModule = parsed.protocol === 'https:' ? https : http;
|
||||
return new Promise((resolve, reject) => {
|
||||
if (lback && lback >= 5) {
|
||||
return reject(new Error('infinite loop!'));
|
||||
}
|
||||
|
||||
const req = httpModule.get(opts, (res) => {
|
||||
if (res.statusCode === 302 || res.statusCode === 301) {
|
||||
if (!lback) {
|
||||
|
Loading…
Reference in New Issue
Block a user