Skip to content

Commit

Permalink
feat: add support for chromium based edge
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Dec 23, 2019
1 parent ed20ad1 commit fe4477f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/browser-dtector.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function BrowserDtector(inputUA) {
const ua = uaFresh.toLowerCase().replace(/\s\s+/g, ' ');

const browserMatch = /(edge)\/([\w.]+)/.exec(ua)
|| /(edg)[/]([\w.]+)/.exec(ua)
|| /(opr)[/]([\w.]+)/.exec(ua)
|| /(jsdom)[/]([\w.]+)/.exec(ua)
|| /(samsungbrowser)[/]([\w.]+)/.exec(ua)
Expand Down Expand Up @@ -102,6 +103,7 @@ function BrowserDtector(inputUA) {
|| browserMatches.crios
|| browserMatches.opr
|| browserMatches.safari
|| browserMatches.edg
);

browserInfo.isIE = !!(
Expand Down
1 change: 1 addition & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const KnownBrowsers = {
chrome: 'Google Chrome',
crios: 'Google Chrome',
edge: 'Microsoft Edge',
edg: 'Microsoft Edge',
fennec: 'Mozilla Firefox',
jsdom: 'JsDOM',
mozilla: 'Mozilla Firefox',
Expand Down
38 changes: 38 additions & 0 deletions specs/ie-edge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,41 @@ test('it should detect `Microsoft Edge` `v18` running in `Xbox`', () => {

browserDetectionTest(...prepareTestData(testData));
});

test('it should detect chromium based edge running in Mac', () => {
const testData = {
userAgent: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/79.0.3945.88 Safari/537.36 Edg/79.0.309.54`,
browserName: 'Microsoft Edge',
version: '79.0.309.54',
shortVersion: '79',
platform: 'Macintosh',
isDesktop: true,
isWebkit: true,
isAndroid: false,
isTablet: false,
isMobile: false,
isIE: false,
};

browserDetectionTest(...prepareTestData(testData));
});

test('it should detect chromium based edge running in Windows', () => {
const testData = {
userAgent: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/75.0.3763.0 Safari/537.36 Edg/75.0.131.0`,
browserName: 'Microsoft Edge',
version: '75.0.131.0',
shortVersion: '75',
platform: 'Windows',
isDesktop: true,
isWebkit: true,
isAndroid: false,
isTablet: false,
isMobile: false,
isIE: false,
};

browserDetectionTest(...prepareTestData(testData));
});

0 comments on commit fe4477f

Please sign in to comment.