Fix bug where "navigator" may be null in SSR mode

This commit is contained in:
Tim Donohue
2024-05-03 09:38:02 -05:00
parent 054043a872
commit 9efcbb20a4

View File

@@ -144,7 +144,7 @@ export class RootComponent implements OnInit {
} }
getBrowserName(): string { getBrowserName(): string {
const userAgent = this._window.nativeWindow.navigator.userAgent; const userAgent = this._window.nativeWindow.navigator?.userAgent;
if (/Firefox/.test(userAgent)) { if (/Firefox/.test(userAgent)) {
return 'firefox'; return 'firefox';
} }
@@ -155,7 +155,7 @@ export class RootComponent implements OnInit {
} }
getOSName(): string { getOSName(): string {
const userAgent = this._window.nativeWindow.navigator.userAgent; const userAgent = this._window.nativeWindow.navigator?.userAgent;
if (/Windows/.test(userAgent)) { if (/Windows/.test(userAgent)) {
return 'windows'; return 'windows';
} }