MCPcopy Index your code
hub / github.com/coder/mux / detectDeviceFromUserAgent

Function detectDeviceFromUserAgent

src/node/services/serverAuthService.ts:146–157  ·  view source on GitHub ↗
(userAgent: string)

Source from the content-addressed store, hash-verified

144}
145
146function detectDeviceFromUserAgent(userAgent: string): string | undefined {
147 const lowerUserAgent = userAgent.toLowerCase();
148
149 if (lowerUserAgent.includes("iphone")) return "iPhone";
150 if (lowerUserAgent.includes("ipad")) return "iPad";
151 if (lowerUserAgent.includes("android")) return "Android";
152 if (lowerUserAgent.includes("mac os x") || lowerUserAgent.includes("macintosh")) return "Mac";
153 if (lowerUserAgent.includes("windows")) return "Windows";
154 if (lowerUserAgent.includes("linux")) return "Linux";
155
156 return undefined;
157}
158
159function buildSessionLabel(userAgent: string | undefined): string {
160 const normalizedUserAgent = normalizeOptionalString(userAgent);

Callers 1

buildSessionLabelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected