Wraps the uadetector UserAgentStringParser to parse browser user agent strings into structured details such as browser name, version and operating system, exposing this to server-side JavaScript. An app can call this directly with a user agent string, or use the convenience methods that parse the user agent header of the current request.


Properties

PropertyReturnsDescription
userAgentReadableUserAgentParses the user agent header of the current request, if there is one. Returns null when there is no current request or the request has no user agent header.
userAgentAsJsonStringParses the user agent header of the current request, if there is one, and returns the result as a JSON string. Returns null when there is no current request or the request has no user agent header.
userAgentAsJsonObjectJSONObjectParses the user agent header of the current request, if there is one, and returns the result as a JSON object. Returns null when there is no current request or the request has no user agent header.

Methods

parse(String userAgent)

Returns: ReadableUserAgent

Parses a user agent string, for example "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", into a structured ReadableUserAgent.

ParameterDescription
userAgentthe raw user agent string to parse

parseAsJson(String userAgent)

Returns: String

Parses the given user agent string and returns the result as a JSON string.

ParameterDescription
userAgentthe raw user agent string to parse

parseAsJsonObject(String userAgent)

Returns: JSONObject

Parses the given user agent string and returns the result as a JSON object.

ParameterDescription
userAgentthe raw user agent string to parse

getUserAgent()

Returns: ReadableUserAgent

Parses the user agent header of the current request, if there is one. Returns null when there is no current request or the request has no user agent header.

getUserAgentAsJsonObject()

Returns: JSONObject

Parses the user agent header of the current request, if there is one, and returns the result as a JSON object. Returns null when there is no current request or the request has no user agent header.

getUserAgentAsJson()

Returns: String

Parses the user agent header of the current request, if there is one, and returns the result as a JSON string. Returns null when there is no current request or the request has no user agent header.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.