Skip to content

Commit

Permalink
fix: isClashMetaForAndroid
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Feb 17, 2024
1 parent 1eee9b9 commit 9cd1b5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/utils/__tests__/useragent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ test('isClashMetaForAndroid', (t) => {
isClashMetaForAndroid('ClashMetaForAndroid/2.8.8.Meta-Alpha', '>=3.0.0'),
false,
)
t.is(isClashMetaForAndroid('ClashMetaForAndroid/2.8.8.Meta'), true)
t.is(isClashMetaForAndroid('ClashMetaForAndroid/2.8.8.Meta', '>=2.8.0'), true)
t.is(isClashMetaForAndroid('ClashMetaForAndroid/2.18.8.Meta'), true)
t.is(
isClashMetaForAndroid('ClashMetaForAndroid/2.8.8.Meta', '>=3.0.0'),
isClashMetaForAndroid('ClashMetaForAndroid/2.18.8.Meta', '>=2.8.0'),
true,
)
t.is(
isClashMetaForAndroid('ClashMetaForAndroid/2.18.8.Meta', '>=3.0.0'),
false,
)
t.is(isClashMetaForAndroid('clash'), false)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/useragent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const isClashMetaForAndroid = (
return false
}

const matcher = /\bClashMetaForAndroid\/([0-9.]{5})\b/i
const matcher = /\bClashMetaForAndroid\/(.+)\b/i
const isClient = matcher.exec(ua)

if (!isClient) {
Expand All @@ -140,7 +140,7 @@ export const isClashMetaForAndroid = (
return true
}

const clientVersion = isClient ? isClient[1] : ''
const clientVersion = isClient ? isClient[1].replace(/\.Meta.*/gi, '') : ''

try {
return satisfies(clientVersion, version)
Expand Down

0 comments on commit 9cd1b5d

Please sign in to comment.