zotonic / ua_classifier

User-Agent Classifier: Erlang version of WeatherChannel's dClass
Apache License 2.0
5 stars 8 forks source link

When the model is an integer the NIF returns an integer not a binary #1

Closed djnym closed 11 years ago

djnym commented 11 years ago

This makes it hard as now sometimes you get a binary, sometimes you get an integer, so for instance

ua_classifier:classify ("Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; Nokia; Lumia 710)"). {ok,[{is_desktop,false}, {is_crawler,false}, {is_wireless_device,true}, {is_tablet,false}, {ajax_support_javascript,true}, {device_os,<<"Windows Phone OS">>}, {displayWidth,480}, {displayHeight,800}, {inputDevices,<<"touchscreen">>}, {parentId,<<"genericNokia">>}, {model,710}, {vendor,<<"Nokia">>}, {id,<<"Lumia710">>}]}

I worked around it application code, but it seems like you might want to have a special case where model is always a binary (seems like you just use make_value in a loop, so you'd have to have a special case for the model key I guess).

arjan commented 11 years ago

:+1:

I don't see any reason, API-wise, why model would be an integer.

mworrell commented 11 years ago

Thanks for reporting this issue. You were the first :)