Skip to content

Commit

Permalink
fix firefox version calculation being one ahead
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelmerro committed Jun 22, 2023
1 parent be1da36 commit a60c243
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
12 changes: 6 additions & 6 deletions app/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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`)
})

0 comments on commit a60c243

Please sign in to comment.