@@ -76,7 +76,7 @@ const modifierKeyNames: string[] = ['Control', 'Alt', 'Meta', 'Shift']
76
76
* platforms.
77
77
* - Ensures modifiers are sorted in a consistent order
78
78
*@param hotkey a hotkey string
79
- *@param platform NOTE: this param is only intended to be used to mock `navigator.platform` in tests
79
+ *@param platform NOTE: this param is only intended to be used to mock `navigator.platform` in tests. `window.navigator.platform` is used by default.
80
80
*@returns {string } normalized representation of the given hotkey string
81
81
*/
82
82
export function normalizeHotkey ( hotkey :string , platform ?:string | undefined ) :NormalizedHotkeyString {
@@ -88,8 +88,11 @@ export function normalizeHotkey(hotkey: string, platform?: string | undefined):
88
88
89
89
const matchApplePlatform = / M a c | i P o d | i P h o n e | i P a d / i
90
90
91
- function localizeMod ( hotkey :string , platform :string = navigator . platform ) :string {
92
- const localModifier = matchApplePlatform . test ( platform ) ?'Meta' :'Control'
91
+ function localizeMod ( hotkey :string , platform ?:string | undefined ) :string {
92
+ const ssrSafeWindow = typeof window === 'undefined' ?undefined :window
93
+ const safePlatform = platform ?? ssrSafeWindow ?. navigator . platform ?? ''
94
+
95
+ const localModifier = matchApplePlatform . test ( safePlatform ) ?'Meta' :'Control'
93
96
return hotkey . replace ( 'Mod' , localModifier )
94
97
}
95
98