OsDetect (OsDetect v1.0.3) View Source

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

Link to this section Summary

Functions

Parse the operating system, browser and platform type from a user-agent string.

Link to this section Functions

Specs

parse(user_agent :: binary()) :: OsDetect.Result.t()

Parse the operating system, browser and platform type 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")
%OsDetect.Result{browser: "chrome", os: "mac os", type: :desktop}
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")
%OsDetect.Result{browser: "webview", os: "android", type: :mobile}
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")
%OsDetect.Result{browser: "firefox", os: "ios", type: :mobile}