Skip to content

Commit 726137b

Browse files
committed
fix: lowercase user-agent in inferBrowser and inferOs to match inferDeviceType
1 parent 63460ab commit 726137b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

apps/server/src/auth/utils.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,26 @@ function inferBrowser(userAgent: string | undefined): string | undefined {
6464
if (!userAgent) {
6565
return undefined;
6666
}
67-
const normalized = userAgent;
68-
if (/Edg\//.test(normalized)) return "Edge";
69-
if (/OPR\//.test(normalized)) return "Opera";
70-
if (/Firefox\//.test(normalized)) return "Firefox";
71-
if (/Chrome\//.test(normalized) || /CriOS\//.test(normalized)) return "Chrome";
72-
if (/Safari\//.test(normalized) && !/Chrome\//.test(normalized)) return "Safari";
73-
if (/Electron\//.test(normalized)) return "Electron";
67+
const normalized = userAgent.toLowerCase();
68+
if (/edg\//.test(normalized)) return "Edge";
69+
if (/opr\//.test(normalized)) return "Opera";
70+
if (/firefox\//.test(normalized)) return "Firefox";
71+
if (/chrome\//.test(normalized) || /crios\//.test(normalized)) return "Chrome";
72+
if (/safari\//.test(normalized) && !/chrome\//.test(normalized)) return "Safari";
73+
if (/electron\//.test(normalized)) return "Electron";
7474
return undefined;
7575
}
7676

7777
function inferOs(userAgent: string | undefined): string | undefined {
7878
if (!userAgent) {
7979
return undefined;
8080
}
81-
const normalized = userAgent;
82-
if (/iPhone|iPad|iPod/.test(normalized)) return "iOS";
83-
if (/Android/.test(normalized)) return "Android";
84-
if (/Mac OS X|Macintosh/.test(normalized)) return "macOS";
85-
if (/Windows NT/.test(normalized)) return "Windows";
86-
if (/Linux/.test(normalized)) return "Linux";
81+
const normalized = userAgent.toLowerCase();
82+
if (/iphone|ipad|ipod/.test(normalized)) return "iOS";
83+
if (/android/.test(normalized)) return "Android";
84+
if (/mac os x|macintosh/.test(normalized)) return "macOS";
85+
if (/windows nt/.test(normalized)) return "Windows";
86+
if (/linux/.test(normalized)) return "Linux";
8787
return undefined;
8888
}
8989

0 commit comments

Comments
 (0)