3rd-Eden / useragent

Useragent parser for Node.js, ported from browserscope.org
MIT License
899 stars 135 forks source link

Microsoft Edge Chromium based being detected as Chrome #143

Open chbomtempo opened 5 years ago

chbomtempo commented 5 years ago

The Microsoft Edge version that is based on Chromium is being detected as Google Chrome. The browser includes a specific string to identify itself.

Here's a sample user agent strings and how they differ:

Microsoft Edge Chromium based:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3782.0 Safari/537.36 Edg/76.0.152.0

Microsoft Edge Classic

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763

As we can see the new Edge is using just Edg instead of Edge to identify itself.

Martii commented 4 years ago

@chbomtempo

I think that's on the beta channel releases. Main Win10 Pro 1903.18.362.239 is still fully spelled out.

Release:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362

Beta channel:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.56 Safari/537.36 Edg/77.0.235.18
vmjames commented 4 years ago

Also on iPhone it is coming through as Mobile Safari Agent { family: 'Mobile Safari', major: '13', minor: '0', patch: '0', source: 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 EdgiOS/44.11.15 Mobile/15E148 Safari/605.1.15' }

dilijev commented 4 years ago

Edge Legacy (EdgeHTML) uses Edge/ in its user agent as @Martii indicated in the first example.

The User-Agent for Stable release of Chromium-based Edge is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71

The User-Agent for Edge iOS uses EdgiOS/ as @vmjames indicated.

The User-Agent for Edge Android uses EdgA/ for example: Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.0 Mobile Safari/537.36 EdgA/44.11.4.4140

nadavb-codefuel commented 4 years ago

Is there any update to that? I don't see the code having a reference to edge chromium!.

luislobo14rap commented 2 years ago
// is-edge.js v1
function isEdge(versionName, userAgent) {
    versionName = versionName ? versionName.toLowerCase() : 'desktop';
    userAgent = userAgent ? userAgent : navigator.userAgent;
    switch (versionName) {
        case 'desktop':
            return (/Edge?\//).test(userAgent);
        case 'chromium':
            return (/Edg\//).test(userAgent);
        case 'legacy':
            return (/Edge\//).test(userAgent);
        case 'mobile':
            return (/Edg(A|iOS)\//).test(userAgent);
        case 'android':
            return (/EdgA\//).test(userAgent);
        case 'ios':
            return (/EdgiOS\//).test(userAgent);
    };
};

Example of use:

if( isEdge('legacy') ){
    // old
};
if( isEdge('chromium') ){
    // new
};