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