docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility that logs and tracks User-Agent strings from HTTP requests while preserving the original raw format for auditing and analytics purposes.
Build a function that accepts a User-Agent string, parses it to extract browser information, and returns both the parsed data and the original unmodified User-Agent string for logging purposes.
Create a function that validates whether a string appears to be a valid User-Agent by attempting to parse it, and returns the original string along with a validity flag.
/**
* Extracts browser information from a User-Agent string and returns
* both the parsed data and the original User-Agent string.
*
* @param {string} userAgent - The User-Agent string to parse
* @returns {{browserName: string, browserVersion: string, originalUA: string}}
* Object containing browser name, version, and original UA string
*/
function extractUserAgent(userAgent) {
// IMPLEMENTATION HERE
}
/**
* Validates whether a string is a parseable User-Agent string.
* Always returns the original string regardless of validity.
*
* @param {string} userAgent - The User-Agent string to validate
* @returns {{isValid: boolean, originalUA: string}}
* Object containing validity flag and original UA string
*/
function validateUserAgent(userAgent) {
// IMPLEMENTATION HERE
}
module.exports = {
extractUserAgent,
validateUserAgent,
};Provides User-Agent parsing and browser detection capabilities.