mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
!581 [新增] UserAgentUtil 解析,增加 MiUI/XiaoMi 浏览器 判断逻辑
Merge pull request !581 from xhal/v5-master
This commit is contained in:
commit
04e0faddf4
@ -45,6 +45,8 @@ public class Browser extends UserAgentInfo {
|
||||
new Browser("Taobao", "taobao", "AliApp\\(TB\\/([\\d\\w\\.\\-]+)\\)"),
|
||||
// UC浏览器
|
||||
new Browser("UCBrowser", "UC?Browser", "UC?Browser\\/([\\d\\w\\.\\-]+)"),
|
||||
// XiaoMi 浏览器
|
||||
new Browser("MiuiBrowser", "MiuiBrowser|mibrowser", "MiuiBrowser\\/([\\d\\w\\.\\-]+)"),
|
||||
// 夸克浏览器
|
||||
new Browser("Quark", "Quark", Other_Version),
|
||||
// 联想浏览器
|
||||
|
@ -36,6 +36,7 @@ public class OS extends UserAgentInfo {
|
||||
new OS("Windows", "windows"), //
|
||||
new OS("OSX", "os x (\\d+)[._](\\d+)", "os x (\\d+([._]\\d+)*)"), //
|
||||
new OS("Android", "Android", "Android (\\d+([._]\\d+)*)"),//
|
||||
new OS("Android", "\\(X\\d+; Linux", "\\(X(\\d+([._]\\d+)*)"),//
|
||||
new OS("Linux", "linux"), //
|
||||
new OS("Wii", "wii", "wii libnup/(\\d+([._]\\d+)*)"), //
|
||||
new OS("PS3", "playstation 3", "playstation 3; (\\d+([._]\\d+)*)"), //
|
||||
|
@ -54,6 +54,7 @@ public class Platform extends UserAgentInfo {
|
||||
IPAD, //
|
||||
IPOD, //
|
||||
IPHONE, //
|
||||
new Platform("Android", "XiaoMi|MI "), //
|
||||
ANDROID, //
|
||||
GOOGLE_TV, //
|
||||
new Platform("htcFlyer", "htc_flyer"), //
|
||||
|
@ -389,4 +389,19 @@ public class UserAgentUtilTest {
|
||||
Assert.assertEquals("Windows", ua.getPlatform().toString());
|
||||
Assert.assertFalse(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXiaoMiTest(){
|
||||
String uaStr = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/89.0.4389.116 Safari/534.24 XiaoMi/MiuiBrowser/16.0.18 swan-mibrowser";
|
||||
final UserAgent ua = UserAgentUtil.parse(uaStr);
|
||||
|
||||
Assert.assertEquals("MiuiBrowser", ua.getBrowser().toString());
|
||||
Assert.assertEquals("16.0.18", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("534.24", ua.getEngineVersion());
|
||||
Assert.assertEquals("Android", ua.getOs().toString());
|
||||
Assert.assertEquals("11", ua.getOsVersion());
|
||||
Assert.assertEquals("Android", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user