Socket
Socket
Sign inDemoInstall

github.com/pm-abhinav-sinha/useragent

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/pm-abhinav-sinha/useragent

Written by https://xojoc.pw. GPLv3 or later. Package useragent parses a user agent string.


Version published

Readme

Source

User agent parsing

useragent is a library written in golang to parse user agent strings.

Usage

First install the library with:

go get xojoc.pw/useragent

useragent is simple to use. First parse a string with useragent.Parse and then access the fields of useragent.UserAgent for the required information. Example:

see godoc for the complete documentation.

How it works?

      Lasciate ogne speranza, voi ch'intrate. -Dante

Parsing user agent strings is a hell. There is no standard for user agent strings, so useragent must use some heuristics. The site http://www.useragentstring.com/ has been invaluable during development. Some relevant links are also:

for the supported user agents see:

If you think useragent doesn't parse correctly a particular user agent string, just open an issue :).

Why this library?

useragent doesn't just split the user agent string and look for specific strings like other parsers, but it has specific parser for the most common browsers/crawlers and falls back to a generic parser for everything else. Its main features are:

  • Simple and stable API.
  • High precision in detection of the most common browsers/crawlers.
  • Detects mobile/tablet devices.
  • OS detection.
  • URL with more information about the user agent (usually it's the home page).
  • Security level detection when reported by browsers.

Who?

useragent was written by Alexandru Cojocaru (http://xojoc.pw) and uses blang/semver to parse versions.

Thanks a lot to @brendanwalters (from http://pendo.io) for the contributions.

Donate!

License

useragent is released under the GPLv3 or later, see COPYING.

FAQs

Last updated on 17 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc