Skip to content

Commit

Permalink
add ability to pass useragent string to the detect function (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgabaydullov authored and DamonOehlman committed Jul 7, 2019
1 parent a5ee118 commit ae86296
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.ts
Expand Up @@ -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);
}
Expand Down

0 comments on commit ae86296

Please sign in to comment.