Skip to content

Commit ae86296

Browse files
rgabaydullovDamonOehlman
authored andcommitted
add ability to pass useragent string to the detect function (#114)
1 parent a5ee118 commit ae86296

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ const operatingSystemRules: OperatingSystemRule[] = [
153153
['Search Bot', SEARCHBOT_OS_REGEX],
154154
];
155155

156-
export function detect(): BrowserInfo | BotInfo | NodeInfo | null {
156+
export function detect(userAgent?: string): BrowserInfo | BotInfo | NodeInfo | null {
157+
if (!!userAgent) {
158+
return parseUserAgent(userAgent);
159+
}
160+
157161
if (typeof navigator !== 'undefined') {
158162
return parseUserAgent(navigator.userAgent);
159163
}

0 commit comments

Comments
 (0)