Open nelsonic opened 1 year ago
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
WTF!? 🤷♂️ 🤦♂️
Don't want to see ads? Pay. Monthly! https://developer.mozilla.org/en-US/plus?ref=nope#subscribe
Sadly, getting the following:
UserAgent.parse("Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53")
%{
browser_family: :unknown,
client: :unknown,
device: :unknown,
os: :unknown,
os_family: :unknown,
user_agent: "Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53"
}
I'd have thought this user_agent
would be fairly straightforward to parse ... 💭
while
reading the code: https://github.com/elixir-inspector/ua_inspector/blob/master/lib/ua_inspector.ex and tests: https://github.com/elixir-inspector/ua_inspector/blob/master/test/ua_inspector/database/init_test.exsI decided to create a thin wrapper that flattens the
user_agent
data into the format that we need.Spoiled for choice on package names:
https://hex.pm/packages/ua
https://hex.pm/packages/user_agent
Todo
ua
package following our usual template 🆕Map
🧑💻user_agent
dataua
package toHex.pm
📦ua
inATM
:shipit:P.S: Sponsoring https://github.com/mneudert for as long as we use the fine work he has done.
#first
Just a way to say "thanks" for the
code
. 🙏