Skip to content

A simple user-agent parsing library based on BrowserScope's UA database.

License

Notifications You must be signed in to change notification settings

channelme/uaparserl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uaparserl

See build results on Travis CI

A simple user-agent parsing library based on BrowserScope's UA database.

Installation

uaparserl is tested with OTP from version 20 onwards. To use it, add uaparserl to your dependencies:

rebar

{deps,[
  {uaparserl, {git, "https://github.com/channelme/uaparserl.git"}}
]}.

mix

def project do
  [
    deps: [{:uaparserl, git: "https://github.com/channelme/uaparserl.git"}]
  ]
end

Enable HiPE

If you want to use a HiPE compiled version, add following code to your rebar.config.

{overrides, [
    {override, uaparserl, [{erl_opts, [{d, 'ENABLE_HIPE'}, inline]}]}
]}.

Usage

Important

Please note that this library returns captures "as is"; it is the responsibility of the developer to ensure that results are properly escaped when used in potentially harmful scenarios.

Also be aware that this library expects and returns strings. You may need to convert the return value to for correct use within your system.

Example

%% Obtain the resource files from BrowserScope's github repository
> uaparserl:update().
ok

%% Parse
> uaparserl:parse("Luminary/70 CFNetwork/978.0.7 Darwin/18.5.0").
[{useragent,[{family,"Luminary"},
             {major,"70"},
             {minor,nil},
             {patch,nil}]},
 {os,[{family,"iOS"},
      {major,"12"},
      {minor,nil},
      {patch,nil},
      {patch_minor,nil}]},
 {device,[{family,"iOS-Device"},
          {brand,"Apple"},
          {model,"iOS-Device"}]}]

Development

We welcome pull requests!

For local development, OTP21 or greater is required. Call make within the project directory for a list of commands that can be used to aid your development process.

Licence

Copyright 2020 Channel.me B.V.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A simple user-agent parsing library based on BrowserScope's UA database.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published