17 lines
723 B
JavaScript
17 lines
723 B
JavaScript
export const OS_FAMILIES = ['windows', 'linux', 'other'];
|
|
|
|
export function normalizeOsFamily(value, fallback = 'other') {
|
|
const text = String(value || '').trim().toLowerCase();
|
|
if (!text) return fallback;
|
|
if (['win', 'windows', 'windows server', 'microsoft windows'].includes(text) || text.includes('windows')) return 'windows';
|
|
if (['linux', 'unix'].includes(text) || /ubuntu|debian|rhel|red hat|centos|fedora|suse|oracle linux|rocky|alma|amazon linux|arch|kali/.test(text)) return 'linux';
|
|
return 'other';
|
|
}
|
|
|
|
export function osFamilyLabel(value) {
|
|
const normalized = normalizeOsFamily(value);
|
|
if (normalized === 'windows') return 'Windows';
|
|
if (normalized === 'linux') return 'Linux';
|
|
return 'Other';
|
|
}
|