Build Status

mobile-detect.lua

A loose port of Mobile-Detect to Lua for NGINX HTTP servers.

The script will detect the device by comparing patterns against a given User-Agent string.
The following device information is available:

Current master branch is using detection logic from Mobile-Detect@2.8.20

Requirements

Usage

init_by_lua_block {
    mobile_detect = require "mobile-detect"
}

content_by_lua_block {
    local user_agent = ngx.var.http_user_agent
    ngx.say(mobile_detect.mobile(user_agent))
    ngx.say(mobile_detect.is('iPhone', user_agent))
    ngx.say(mobile_detect.is('bot', user_agent))
}

Contributing

Your contribution is welcome.
If you want new devices to be supported, please contribute to Mobile-Detect.
Changes there will cascade to this project.

If you have bug-fixes, new features, etc for this project, please follow the below steps:
Note: To generate source from template, it requires Mobile-Detect as a sibling directory to mobile-detect.lua

Testing

License

MIT-License (see LICENSE file)