Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/http.ts>parseUserAgent

A JavaScript extension package for building strong and modern applications.
Latest
function parseUserAgent
import { parseUserAgent } from "https://deno.land/x/ayonli_jsext@v0.9.72/http.ts";

Parses the User-Agent header or the navigator.userAgent property.

Examples

Example 1

const ua = parseUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
console.log(ua);
// {
//     name: "Chrome",
//     version: "91.0.4472.124",
//     runtime: { identity: "chrome", version: "91.0.4472.124" },
//     platform: "windows",
//     mobile: false,
//     raw: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
// }

Parameters

str: string