@@ -29,7 +29,7 @@ class UserAgentParserImpl implements UserAgentParser {
29
29
"rv:" , "build" , "bot" , "like gecko" , "applewebkit" , "trident" , "mozilla" , "windows nt 4" , "windows nt 5.0" ,
30
30
"windows nt 5.1" , "windows nt 5.2" , "windows nt 6.0" , "windows nt 6.1" , "windows nt 6.2" , "windows nt 6.3" ,
31
31
"windows nt 10.0" , "android?4.0" , "android?4.1" , "android?4.2" , "android?4.3" , "android?4.4" , "android?2.3" ,
32
- "android?5" };
32
+ "android?5" };
33
33
34
34
// Common prefixes to filter irrelevant rules and speed up processing
35
35
static final String [] FILTER_PREFIXES = {"mozilla/5.0" , "mozilla/4" };
@@ -64,6 +64,9 @@ class UserAgentParserImpl implements UserAgentParser {
64
64
*/
65
65
@ Override
66
66
public Capabilities parse (final String userAgent ) {
67
+ if (userAgent == null || userAgent .length () == 0 ) {
68
+ return myDefaultCapabilities ;
69
+ }
67
70
68
71
final SearchableString searchString = myDomain .getSearchableString (userAgent .toLowerCase ());
69
72
@@ -110,9 +113,10 @@ Filter[] buildFilters() {
110
113
for (final String pattern : FILTER_PREFIXES ) {
111
114
result .add (createPrefixFilter (pattern ));
112
115
}
113
-
116
+
114
117
// Build filters for specific contains constraints
115
- final List <Filter > commonFilters = Stream .of (COMMON ).parallel ().map (this ::createContainsFilter ).collect (toList ());
118
+ final List <Filter > commonFilters =
119
+ Stream .of (COMMON ).parallel ().map (this ::createContainsFilter ).collect (toList ());
116
120
result .addAll (commonFilters );
117
121
118
122
return result .toArray (new Filter [0 ]);
0 commit comments