fix(ui): isMacOS always returned false on Macs + plugin-logic tests (+49)
Coverage work found a 3rd real bug: isMacOS() compared os.name against the legacy 'Mac OS' string, but ua-parser-js v2 reports 'macOS' — so it was dead, and Mac users saw "Ctrl + k" instead of "⌘ + k" in the editor toolbar, search, and settings shortcut hints. Now accepts both 'macOS' and 'Mac OS'. Suites (via subagent, verified): via-servers (10 — power/popularity server selection), bad-words (9), syntaxHighlight tokenize (14), plugins/utils getEmoticonSearchStr (5), imageCompression formatFileSize/isCompressible (5), user-agent (6, now asserting the fixed behavior). Full suite now 501 tests, all passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,12 @@ import { UAParser } from 'ua-parser-js';
|
||||
|
||||
export const ua = () => UAParser(window.navigator.userAgent);
|
||||
|
||||
export const isMacOS = () => ua().os.name === 'Mac OS';
|
||||
// ua-parser-js reports macOS as 'macOS' (v2+); older versions used 'Mac OS'.
|
||||
// Accept both so the ⌘-vs-Ctrl shortcut hints render correctly on real Macs.
|
||||
export const isMacOS = () => {
|
||||
const name = ua().os.name;
|
||||
return name === 'macOS' || name === 'Mac OS';
|
||||
};
|
||||
|
||||
export const mobileOrTablet = (): boolean => {
|
||||
const userAgent = ua();
|
||||
|
||||
Reference in New Issue
Block a user