Skip to content

Commit 48d481a

Browse files
authored
refactor: use semver to parse header and perform comparisons (#1673)
Signed-off-by: Adam Setch <[email protected]>
1 parent 60c0ced commit 48d481a

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
"@types/react": "19.0.1",
148148
"@types/react-dom": "19.0.2",
149149
"@types/react-router-dom": "5.3.3",
150+
"@types/semver": "^7.5.8",
150151
"autoprefixer": "10.4.20",
151152
"axios": "1.7.9",
152153
"class-variance-authority": "0.7.1",
@@ -171,6 +172,7 @@
171172
"postcss-loader": "8.1.1",
172173
"react-final-form": "6.5.9",
173174
"rimraf": "6.0.1",
175+
"semver": "7.6.3",
174176
"tailwind-merge": "2.5.5",
175177
"tailwindcss": "3.4.16",
176178
"terser-webpack-plugin": "5.3.10",

pnpm-lock.yaml

Lines changed: 14 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/utils/features.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import semver from 'semver';
12
import type { Account } from '../types';
23
import { isEnterpriseServerHost } from './helpers';
34

@@ -10,8 +11,7 @@ import { isEnterpriseServerHost } from './helpers';
1011
export function isMarkAsDoneFeatureSupported(account: Account): boolean {
1112
if (isEnterpriseServerHost(account.hostname)) {
1213
if (account.version) {
13-
const version = account?.version.split('.').map(Number);
14-
return version[0] >= 3 && version[1] >= 13;
14+
return semver.gte(semver.coerce(account.version), '3.13.0');
1515
}
1616

1717
return false;
@@ -30,8 +30,7 @@ export function isAnsweredDiscussionFeatureSupported(
3030
): boolean {
3131
if (isEnterpriseServerHost(account.hostname)) {
3232
if (account.version) {
33-
const version = account?.version.split('.').map(Number);
34-
return version[0] >= 3 && version[1] >= 12;
33+
return semver.gte(semver.coerce(account.version), '3.12.0');
3534
}
3635

3736
return false;

0 commit comments

Comments
 (0)