henrylearn2rock / BrowscapCFC

Detect browser capabilities from user agent string from CGI using `browscap.ini`
9 stars 6 forks source link

Does not work on Lucee #4

Open redtopia opened 7 years ago

redtopia commented 7 years ago

Lucee passes arrays by reference, so convertPatternToRegex() ends up modifying the source array, preventing any matches in getBrowser().

henrylearn2rock commented 7 years ago

Sounds like an easy fix. Patch is welcomed

redtopia commented 7 years ago

Not sure what can be done about performance. I'm getting about 200ms for a lookup. Also, the entire dataset requires about 125 MB of memory. I wonder if there's any way around doing a sequential search to find the best regex for UA.

There's a java library here: https://github.com/ankushs92/Browscap4j which could be useful. Instead of implementing it in CF, a CFC could be written as a wrapper around the java library. Looks like the average response time is a little better than 1/2 as much as doing a sequential search.

redtopia commented 7 years ago

I added some caching and I'm getting 0 ms returned (using EHCache), so that's also an option.