release: v2.11.2
This commit is contained in:
@@ -50,6 +50,27 @@ const SCREEN_CONTROL_COMMAND_LABELS = Object.freeze({
|
||||
});
|
||||
const { fetchAppSettings } = require('./app-settings');
|
||||
|
||||
function formatUserAgentLabel(userAgent) {
|
||||
const value = String(userAgent || '').trim();
|
||||
if (!value) return '';
|
||||
const browserMatch = value.match(/(?:Edg|OPR|Chrome|Firefox|Version|Electron)\/([\d.]+)/i);
|
||||
let browser = '';
|
||||
if (/Edg\//i.test(value)) browser = 'Edge';
|
||||
else if (/OPR\//i.test(value)) browser = 'Opera';
|
||||
else if (/Electron\//i.test(value)) browser = 'Electron';
|
||||
else if (/Chrome\//i.test(value)) browser = 'Chrome';
|
||||
else if (/Firefox\//i.test(value)) browser = 'Firefox';
|
||||
else if (/Version\/.*Safari\//i.test(value)) browser = 'Safari';
|
||||
const browserLabel = browserMatch && browser ? browser + ' ' + browserMatch[1] : browser;
|
||||
let operatingSystem = '';
|
||||
if (/Windows NT/i.test(value)) operatingSystem = 'Windows';
|
||||
else if (/Macintosh|Mac OS X/i.test(value)) operatingSystem = 'macOS';
|
||||
else if (/Android/i.test(value)) operatingSystem = 'Android';
|
||||
else if (/iPhone|iPad|iPod/i.test(value)) operatingSystem = 'iOS';
|
||||
else if (/Linux/i.test(value)) operatingSystem = 'Linux';
|
||||
return [browserLabel, operatingSystem].filter(Boolean).join(' on ') || value;
|
||||
}
|
||||
|
||||
function normalizeDetails(details) {
|
||||
if (details === undefined || details === null) {
|
||||
return null;
|
||||
@@ -136,6 +157,7 @@ module.exports = {
|
||||
AUDIT_CATEGORY_LABELS,
|
||||
SCREEN_CONTROL_COMMAND_KEYS,
|
||||
SCREEN_CONTROL_COMMAND_LABELS,
|
||||
formatUserAgentLabel,
|
||||
getRequestMetadata,
|
||||
buildAuditChanges,
|
||||
recordAuditEvent,
|
||||
|
||||
Reference in New Issue
Block a user