Skip to content

Commit 9065635

Browse files
Cope when window is undefined
1 parent 82511cb commit 9065635

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/bluetooth-device-wrapper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ const deviceIdToWrapper: Map<string, BluetoothDeviceWrapper> = new Map();
3030
const connectTimeoutDuration: number = 10000;
3131

3232
function findPlatform(): string | undefined {
33-
const navigator: any = window.navigator;
33+
const navigator: any =
34+
typeof window !== "undefined" ? window.navigator : undefined;
35+
if (!navigator) {
36+
return "unknown";
37+
}
3438
const platform = navigator.userAgentData?.platform;
3539
if (platform) {
3640
return platform;

0 commit comments

Comments
 (0)