docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a simple command-line tool that analyzes User-Agent strings and outputs structured browser information. The tool should read User-Agent strings from standard input and output browser details in a consistent format.
Create a program that:
Browser: <name> <version>Given a Chrome User-Agent string "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", the output should be "Browser: Chrome 120.0.0.0" @test
Given a Firefox User-Agent string "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0", the output should be "Browser: Firefox 121.0" @test
Given a Safari User-Agent string "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15", the output should be "Browser: Safari 17.1" @test
Given an Edge User-Agent string "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0", the output should be "Browser: Microsoft Edge 120.0.0.0" @test
/**
* Extracts browser information from a User-Agent string
* @param {string} userAgent - The User-Agent string to parse
* @returns {Object} An object with browserName and browserVersion properties
*/
function extractBrowserInfo(userAgent) {
// Implementation here
}
/**
* Formats browser information as a string
* @param {string} browserName - The name of the browser
* @param {string} browserVersion - The version of the browser
* @returns {string} Formatted string "Browser: <name> <version>"
*/
function formatBrowserOutput(browserName, browserVersion) {
// Implementation here
}
module.exports = {
extractBrowserInfo,
formatBrowserOutput
};Provides browser detection and User-Agent parsing capabilities.