diff --git a/src/index.ts b/src/index.ts index 502cefd..f0c67ab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -153,7 +153,11 @@ const operatingSystemRules: OperatingSystemRule[] = [ ['Search Bot', SEARCHBOT_OS_REGEX], ]; -export function detect(): BrowserInfo | BotInfo | NodeInfo | null { +export function detect(userAgent?: string): BrowserInfo | BotInfo | NodeInfo | null { + if (!!userAgent) { + return parseUserAgent(userAgent); + } + if (typeof navigator !== 'undefined') { return parseUserAgent(navigator.userAgent); }