Giter Site home page Giter Site logo

beam-community / ua_parser Goto Github PK

View Code? Open in Web Editor NEW
42.0 42.0 10.0 427 KB

UserAgentParser implementation for Elixir

License: Apache License 2.0

Elixir 74.88% JavaScript 5.15% CSS 14.65% HTML 5.33%
elixir elixir-lang plug user-agent user-agent-parser

ua_parser's People

Contributors

btkostner avatar clarkthan avatar darrenklein avatar dependabot[bot] avatar doomspork avatar dukex avatar ezrafree avatar hanspagh avatar kianmeng avatar maartenvanvliet avatar nathany avatar tommorris avatar webnard avatar ybur-yug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ua_parser's Issues

Webview within iPadOS parsed as Apple Mail

Yesterday I encountered a behavior like as a title.

Situation: When sent a https request from my iPad app to my phoenix app that using ua_parser

UserAgent string is Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko)

"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko)" |> UAParser.parse()
%UAParser.UA{
  device: %UAParser.Device{brand: nil, family: nil, model: nil},
  family: "Apple Mail",
  os: %UAParser.OperatingSystem{
    family: "Mac OS X",
    version: %UAParser.Version{
      major: "10",
      minor: "15",
      patch: nil,
      patch_minor: nil
    }
  },
  version: %UAParser.Version{
    major: "605",
    minor: "1",
    patch: "15",
    patch_minor: nil
  }
}

Chromebook with Linux OS parsed as Android

Hi again! I was testing parsing some different user agent strings, and I tried out a string for a Chromebook running Linux -

iex(1)> str = "Mozilla/5.0 (Linux; Android 7.1.1; Acer Chromebook R13 (CB5-312T) Build/R66-10452.85.0; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Safari/537.36"
iex(2)> str |> UAParser.parse()

%UAParser.UA{
  device: %UAParser.Device{
    brand: "Acer",
    family: "Acer Chromebook R13 (CB5-312T)",
    model: "Chromebook R13 (CB5-312T)"
  },
  family: "Chrome Mobile WebView",
  os: %UAParser.OperatingSystem{
    family: "Android",
    version: %UAParser.Version{
      major: "7",
      minor: "1",
      patch: "1",
      patch_minor: nil
    }
  },
  version: %UAParser.Version{
    major: "56",
    minor: "0",
    patch: "2924",
    patch_minor: "87"
  }
}

Among other things, I expected that the os.family would be "Linux", rather than "Android".

Unfortunately, I don't own a Chromebook with Linux, so I can only go by the sample user agent strings I found at http://www.webapps-online.com/online-tools/user-agent-strings/dv/brand642387/chromebook

What do y'all think about this? If you feel it's a legit issue, I'd be happy to pick it up and open a PR for it. Again, I can't verify the accuracy of the UA string, and this was the only example that I could find, so if you feel the source isn't reliable enough to warrant making any changes, I'd certainly understand.

Thanks for all of your hard work!

Regex misses Chrome/Chromium minor patch version

Hello, thank you so much for this extremely helpful library!

I noticed that the regex used for Chromium/Chrome fails to pick up the minor patch version - this isn't a big deal, but it'd be nice to have it. Correct me if I'm wrong, but I believe that the regex would need to be:

- regex: '(Chromium|Chrome)/(\d+)\.(\d+)(?:\.(\d+))(?:\.(\d+))?'

That's line 437 of patterns.yml. Otherwise, that value comes back as nil.

What do you think?

Expose if is desktop or mobile

Hi!
I need to detect if the user_agent is mobile or not. I found this solution with regex for other languages, but I think it fits well here.
We can add a field kind with options :desktop, :mobile, or nil to the device.

I'm opening the issue to discuss the implementation, after that, I would like to implement this.

Thanks!

Problem parsing certain agent strings

We've run across a handful of user agents that don't parse well, all of the following are missing the OS values:

  • Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
  • Mozilla/5.0 (Windows NT 6.1%3B Trident/7.0%3B SLCC2%3B .NET CLR 2.0.50727%3B .NET CLR 3.5.30729%3B .NET CLR 3.0.30729%3B Media Center PC 6.0%3B .NET4.0C%3B rv:11.0) like Gecko
  • Mozilla/5.0 (Windows NT 6.1%3B WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
    Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)
  • Mozilla/5.0 (Macintosh%3B Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
  • Mozilla/5.0 (Windows NT 6.1%3B WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
  • Mozilla/5.0 (Windows NT 6.1%3B WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
  • Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)
  • Mozilla/5.0 (Macintosh; Intel Mac OS X) Word/0.0.0
  • Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; ms-office; MSOffice 15)
  • Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko
  • Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
  • Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/7.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; ms-office; MSOffice 15)
  • Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
  • Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
  • Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; ms-office; MSOffice 16)

One in particular is missing both OS and browser version:

  • Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.