Skip to content

Commit 7b4a6d8

Browse files
authored
feat: add support for Fedora (linux) (#3)
1 parent 6f99ff1 commit 7b4a6d8

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

dist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getPlatformFromUserAgent (ua) {
3434
// aix darwin freebsd linux openbsd sunos win32
3535
if (/mac/i.test(name)) { return 'darwin' }
3636
if (/windows/i.test(name)) { return 'win32' }
37-
if (/ubuntu|linux|gentoo|centos|redhat|suse|unix/i.test(name)) { return 'linux' }
37+
if (/ubuntu|linux|gentoo|centos|redhat|suse|unix|fedora/i.test(name)) { return 'linux' }
3838
if (/freebsd/i.test(name)) { return 'freebsd' }
3939
if (/openbsd/i.test(name)) { return 'openbsd' }
4040

src.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getPlatformFromUserAgent (ua) {
3434
// aix darwin freebsd linux openbsd sunos win32
3535
if (/mac/i.test(name)) return 'darwin'
3636
if (/windows/i.test(name)) return 'win32'
37-
if (/ubuntu|linux|gentoo|centos|redhat|suse|unix/i.test(name)) return 'linux'
37+
if (/ubuntu|linux|gentoo|centos|redhat|suse|unix|fedora/i.test(name)) return 'linux'
3838
if (/freebsd/i.test(name)) return 'freebsd'
3939
if (/openbsd/i.test(name)) return 'openbsd'
4040

test/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ describe('getPlatformFromUserAgent', () => {
5757
getPlatformFromUserAgent(ua).should.eq('linux')
5858
})
5959

60+
it('returns `linux` for Fedora', () => {
61+
const ua = 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0'
62+
getPlatformFromUserAgent(ua).should.eq('linux')
63+
})
64+
6065
it('returns `win32` for Windows', () => {
6166
const ua = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.71 (KHTML like Gecko) WebVideo/1.0.1.10 Version/7.0 Safari/537.71'
6267
getPlatformFromUserAgent(ua).should.eq('win32')

0 commit comments

Comments
 (0)