@@ -88,32 +88,31 @@ impl UserAgent {
88
88
89
89
#[ must_use]
90
90
pub fn parse ( user_agent : String ) -> Self {
91
- if !user_agent. contains ( "Mozilla/" ) {
92
- if let Some ( ( name, version, model, os, os_version) ) =
91
+ if !user_agent. contains ( "Mozilla/" )
92
+ && let Some ( ( name, version, model, os, os_version) ) =
93
93
UserAgent :: parse_custom ( & user_agent)
94
- {
95
- let mut device_type = DeviceType :: Unknown ;
96
-
97
- // Handle mobile simple mobile devices
98
- if os == "Android" || os == "iOS" {
99
- device_type = DeviceType :: Mobile ;
100
- }
101
-
102
- // Handle iPads
103
- if model. contains ( "iPad" ) {
104
- device_type = DeviceType :: Tablet ;
105
- }
106
-
107
- return Self {
108
- name : Some ( name. to_owned ( ) ) ,
109
- version : Some ( version. to_owned ( ) ) ,
110
- os : Some ( os. to_owned ( ) ) ,
111
- os_version : os_version. map ( std:: borrow:: ToOwned :: to_owned) ,
112
- model : Some ( model. to_owned ( ) ) ,
113
- device_type,
114
- raw : user_agent,
115
- } ;
94
+ {
95
+ let mut device_type = DeviceType :: Unknown ;
96
+
97
+ // Handle mobile simple mobile devices
98
+ if os == "Android" || os == "iOS" {
99
+ device_type = DeviceType :: Mobile ;
100
+ }
101
+
102
+ // Handle iPads
103
+ if model. contains ( "iPad" ) {
104
+ device_type = DeviceType :: Tablet ;
116
105
}
106
+
107
+ return Self {
108
+ name : Some ( name. to_owned ( ) ) ,
109
+ version : Some ( version. to_owned ( ) ) ,
110
+ os : Some ( os. to_owned ( ) ) ,
111
+ os_version : os_version. map ( std:: borrow:: ToOwned :: to_owned) ,
112
+ model : Some ( model. to_owned ( ) ) ,
113
+ device_type,
114
+ raw : user_agent,
115
+ } ;
117
116
}
118
117
119
118
let mut model = None ;
@@ -205,11 +204,11 @@ impl UserAgent {
205
204
}
206
205
207
206
// Special handling for Electron applications e.g. Element Desktop
208
- if user_agent. contains ( "Electron/" ) {
209
- if let Some ( app) = UserAgent :: parse_electron ( & user_agent) {
210
- result . name = app . 0 ;
211
- result. version = app. 1 ;
212
- }
207
+ if user_agent. contains ( "Electron/" )
208
+ && let Some ( app) = UserAgent :: parse_electron ( & user_agent)
209
+ {
210
+ result. name = app. 0 ;
211
+ result . version = app . 1 ;
213
212
}
214
213
215
214
Self {
0 commit comments