From a60c243bf7de2c282c66757111adf5ca2b61eba1 Mon Sep 17 00:00:00 2001 From: Jelmer van Arnhem Date: Thu, 22 Jun 2023 21:03:27 +0200 Subject: [PATCH] fix firefox version calculation being one ahead --- CHANGELOG.md | 1 + app/util.js | 4 ++-- app/util.test.js | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70bbfcbd..40f354c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The releases of Vieb aim to follow [semantic versioning](https://semver.org). - Errors for ipc calls to webview that are still being created by only sending data to webview with ready dom - First navigation issue that requires a second mouse click to navigate by delaying the useragent reroll - Relative feed URLs only returning the path (they are now prefixed with the current url as needed) +- Firefox version calculation being ahead of time due to delayed Firefox releases ### Versions diff --git a/app/util.js b/app/util.js index 83ca0cc2..9892bd08 100644 --- a/app/util.js +++ b/app/util.js @@ -320,8 +320,8 @@ const defaultUseragent = () => { const firefoxVersion = () => { const daysSinceBase = (new Date().getTime() - - new Date(2021, 7, 10).getTime()) / 86400000 - return `${91 + Math.floor(daysSinceBase / 28)}.0` + - new Date(2023, 4, 9).getTime()) / 86400000 + return `${113 + Math.floor(daysSinceBase / 28)}.0` } const firefoxUseragent = () => { diff --git a/app/util.test.js b/app/util.test.js index ca5a4fea..c276e8b0 100644 --- a/app/util.test.js +++ b/app/util.test.js @@ -501,9 +501,9 @@ test(`Expand path to resolve homedir and downloads`, () => { }) test(`Firefox version should increment by date`, () => { - const firstMockDate = new Date("2021-03-26") - const secondMockDate = new Date("2021-08-26") - const thirdMockDate = new Date("2022-03-15") + const firstMockDate = new Date("2023-06-05") + const secondMockDate = new Date("2023-06-06") + const thirdMockDate = new Date("2023-07-04") const sys = UTIL.userAgentPlatform() global.Date = class extends Date { constructor(...date) { @@ -513,7 +513,7 @@ test(`Firefox version should increment by date`, () => { return firstMockDate } } - let ver = 86 + let ver = 113 expect(UTIL.firefoxUseragent()).toBe( `Mozilla/5.0 (${sys}; rv:${ver}.0) Gecko/20100101 Firefox/${ver}.0`) global.Date = class extends Date { @@ -524,7 +524,7 @@ test(`Firefox version should increment by date`, () => { return secondMockDate } } - ver = 91 + ver = 114 expect(UTIL.firefoxUseragent()).toBe( `Mozilla/5.0 (${sys}; rv:${ver}.0) Gecko/20100101 Firefox/${ver}.0`) global.Date = class extends Date { @@ -535,7 +535,7 @@ test(`Firefox version should increment by date`, () => { return thirdMockDate } } - ver = 98 + ver = 115 expect(UTIL.firefoxUseragent()).toBe( `Mozilla/5.0 (${sys}; rv:${ver}.0) Gecko/20100101 Firefox/${ver}.0`) })