diff --git a/flow-server/src/main/java/com/vaadin/flow/shared/BrowserDetails.java b/flow-server/src/main/java/com/vaadin/flow/shared/BrowserDetails.java index df765ada4c2..06089b9e7e8 100644 --- a/flow-server/src/main/java/com/vaadin/flow/shared/BrowserDetails.java +++ b/flow-server/src/main/java/com/vaadin/flow/shared/BrowserDetails.java @@ -94,7 +94,9 @@ public BrowserDetails(String userAgent) { isSafari = !isChrome && !isIE && userAgent.contains("safari"); isFirefox = userAgent.contains(" firefox/"); - if (userAgent.contains(" edge/")) { + if (userAgent.contains(" edge/") || userAgent.contains(" edg/") + || userAgent.contains(" edga/") + || userAgent.contains(" edgios/")) { isEdge = true; isChrome = false; isOpera = false; @@ -212,6 +214,14 @@ public BrowserDetails(String userAgent) { parseVersionString(safeSubstring(userAgent, i, i + 5)); } else if (isEdge) { int i = userAgent.indexOf(" edge/") + 6; + if (userAgent.contains(" edg/")) { + i = userAgent.indexOf(" edg/") + 5; + } else if (userAgent.contains(" edga/")) { + i = userAgent.indexOf(" edga/") + 6; + } else if (userAgent.contains(" edgios/")) { + i = userAgent.indexOf(" edgios/") + 8; + } + parseVersionString(safeSubstring(userAgent, i, i + 8)); } } catch (Exception e) { diff --git a/flow-server/src/test/java/com/vaadin/flow/shared/BrowserDetailsTest.java b/flow-server/src/test/java/com/vaadin/flow/shared/BrowserDetailsTest.java index f832b13ead9..4e60e9987ee 100644 --- a/flow-server/src/test/java/com/vaadin/flow/shared/BrowserDetailsTest.java +++ b/flow-server/src/test/java/com/vaadin/flow/shared/BrowserDetailsTest.java @@ -67,6 +67,12 @@ public class BrowserDetailsTest extends TestCase { private static final String IPHONE_IOS_11_FACEBOOK_BROWSER = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E302 [FBAN/MessengerForiOS;FBAV/165.0.0.45.95;FBBV/107115338;FBDV/iPhone10,6;FBMD/iPhone;FBSN/iOS;FBSV/11.3.1;FBSS/3;FBCR/DNA;FBID/phone;FBLC/en_GB;FBOP/5;FBRV/0]"; private static final String IPHONE_IOS_11_FIREFOX = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) FxiOS/11.1b10377 Mobile/15B202 Safari/604.3.5"; + private static final String EDGE_100 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36 Edg/100.0.1185.29"; + + private static final String EDGE_99_MAC = "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_3_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/99.0.1150.36"; + private static final String EDGE_97_ANDROID = "Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.79 Mobile Safari/537.36 EdgA/97.0.1072.69"; + private static final String EDGE_97_IOS = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 EdgiOS/97.1072.69 Mobile/15E148 Safari/605.1.15"; + private static final String GOOGLE_APP_IPHONE_14_7 = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/117.0.321844219 Mobile/15E148 Safari/604.1"; public void testSafari3() { @@ -547,6 +553,38 @@ public void testEdgeWindows10() { assertEs5(bd); } + public void testEdgeWindows11() { + BrowserDetails bd = new BrowserDetails(EDGE_100); + assertEdge(bd); + assertBrowserMajorVersion(bd, 100); + assertBrowserMinorVersion(bd, 0); + assertWindows(bd, false); + } + + public void testEdgeMac() { + BrowserDetails bd = new BrowserDetails(EDGE_99_MAC); + assertEdge(bd); + assertBrowserMajorVersion(bd, 99); + assertBrowserMinorVersion(bd, 0); + assertMacOSX(bd); + } + + public void testEdgeAndroid() { + BrowserDetails bd = new BrowserDetails(EDGE_97_ANDROID); + assertEdge(bd); + assertBrowserMajorVersion(bd, 97); + assertBrowserMinorVersion(bd, 0); + assertAndroid(bd, 10, -1); + } + + public void testEdgeIOS() { + BrowserDetails bd = new BrowserDetails(EDGE_97_IOS); + assertEdge(bd); + assertBrowserMajorVersion(bd, 97); + assertBrowserMinorVersion(bd, 1072); + assertIPhone(bd); + } + public void testEclipseMac_safari91() { BrowserDetails bd = new BrowserDetails(ECLIPSE_MAC_SAFARI_91); assertWebKit(bd);