OsDetect (OsDetect v0.1.2) View Source

A fast and User Agent parser which only returns the operating system.

Link to this section Summary

Functions

Parse the operating system from a user-agent string

Link to this section Functions

Specs

parse(user_agent :: binary() | nil) :: operating_system :: binary() | nil

Parse the operating system from a user-agent string

Examples

iex> OsDetect.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36")
"macos"
iex> OsDetect.parse("Mozilla/5.0 (Linux; Android 10; Pixel 3 XL Build/QQ3A.200605.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36 GSA/11.18.11.21.arm64")
"android"
iex> OsDetect.parse("Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML}, like Gecko) FxiOS/7.5b3349 Mobile/14F89 Safari/603.2.4")
"ios"