| 288 | } |
| 289 | |
| 290 | function isServer(res: UAParser.IResult) { |
| 291 | // Matches user agents like "Go-http-client/1.0" or "Go Http Client/1.0" |
| 292 | // It should just match the first name (with optional spaces) and version |
| 293 | if (SINGLE_NAME_VERSION_REGEX.test(res.ua)) { |
| 294 | return true; |
| 295 | } |
| 296 | |
| 297 | // If all of these are undefined, we can consider it a server |
| 298 | return ( |
| 299 | res.os.name === undefined && |
| 300 | res.browser.name === undefined && |
| 301 | res.device.vendor === undefined && |
| 302 | res.device.model === undefined |
| 303 | ); |
| 304 | } |
| 305 | |
| 306 | export function getDevice(ua: string, model?: string) { |
| 307 | // Check for known phone models first (from top brands) |