Create WURFL patch matching partial user-agent
I'm using WURFL to identify whether a user is on a mobile device. Some User-Agent strings are incorrectly recognized as mobile devices which in turn causes the content-type to be set incorrectly.
Here an example of a real life user agent behaving like this:
Mozilla/5.0 (GTmetrix http://gtmetrix.com/; X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
The content-type then is set to application/vnd.wap.xhtml+xml
instead of text/html
.
I would like to add an entry to the web_browsers_patch.xml file in order to recognize it as a non mobile browser.
The following works:
<device id="mozilla_ver5"
user_agent="Mozilla/5.0 (GTmetrix http://gtmetrix开发者_C百科.com/; X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13"
fall_back="generic_web_browser" />
However, in order to no have to add all possible user agent variations, I would like to match it partially. Something like:
<device id="mozilla_ver5"
user_agent="Mozilla/5.0 (GTmetrix"
fall_back="generic_web_browser" />
Unfortunately, this does not work - the content type of the page is again set incorrectly.
Is it possible to add a WURFL patch matching partial user agent strings? How?
(Related bonus question: How can I determine to which profile a user agent string was matched?)
I'm using the 51Degrees Foundation API available on http://51degrees.codeplex.com/
If you are using 51Degrees, you can take apart some of the objects it returns. Take a look here : http://51degrees.mobi/Support/Documentation/Foundation/WURFLMappingTable.aspx
This should get you the user_agent and a bevy of other properties to suit your needs.
精彩评论