From 5a61e7c6c1fa847c4f826641058bef6f86e57cd8 Mon Sep 17 00:00:00 2001 From: Billy Richardson Date: Wed, 8 Jun 2022 23:52:08 -0700 Subject: [PATCH] Handle GitHub changes to fetch latest `yt-dlp` --- modules/BinaryUpdater.js | 6 +++--- tests/BinaryUpdater.test.js | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/BinaryUpdater.js b/modules/BinaryUpdater.js index d9647629..276c0d60 100644 --- a/modules/BinaryUpdater.js +++ b/modules/BinaryUpdater.js @@ -72,11 +72,11 @@ class BinaryUpdater { return null; } if (res.status === 302) { - const versionRegex = res.data.match(/[0-9]+\.[0-9]+\.[0-9]+/); - const urlRegex = res.data.match(/(?<=").+?(?=")/); + const redirectUrl = res.headers.location; + const versionRegex = redirectUrl.match(/[0-9]+\.[0-9]+\.[0-9]+/); return { remoteVersion: versionRegex ? versionRegex[0] : null, - remoteUrl: urlRegex ? urlRegex[0] : null, + remoteUrl: redirectUrl, }; } else { console.error('Did not get redirect for the latest version link. Status: ' + err.response.status); diff --git a/tests/BinaryUpdater.test.js b/tests/BinaryUpdater.test.js index abeab5bf..7324ef09 100644 --- a/tests/BinaryUpdater.test.js +++ b/tests/BinaryUpdater.test.js @@ -67,7 +67,6 @@ describe('getRemoteVersion', () => { const axiosGetSpy = jest.spyOn(axios, 'get').mockRejectedValue({ response: { status: 302, - data: "", headers: { location: redirectURL }