From 89a2e0255081ba23876122314db3251457f63f20 Mon Sep 17 00:00:00 2001 From: Jamie Stivala Date: Thu, 8 Feb 2024 18:07:35 +0100 Subject: [PATCH] Fixed an issue where updatejs was not updating due to redirect 302 (#263) * Fixed an issue where updatejs was not updating due to redirect 302 --- scripts/updatedb.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/updatedb.js b/scripts/updatedb.js index b207b705..a8738225 100644 --- a/scripts/updatedb.js +++ b/scripts/updatedb.js @@ -181,8 +181,10 @@ function check(database, cb) { function onResponse(response) { var status = response.statusCode; - - if (status !== 200) { + + if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308) { + return https.get(getHTTPOptions(response.headers.location), onResponse); + } else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); client.abort(); process.exit(1); @@ -243,7 +245,9 @@ function fetch(database, cb) { function onResponse(response) { var status = response.statusCode; - if (status !== 200) { + if(status === 301 || status === 302 || status === 303 || status === 307 || status === 308) { + return https.get(getHTTPOptions(response.headers.location), onResponse); + } else if (status !== 200) { console.log(chalk.red('ERROR') + ': HTTP Request Failed [%d %s]', status, http.STATUS_CODES[status]); client.abort(); process.exit(1);