31 lines
875 B
TypeScript
31 lines
875 B
TypeScript
/**
|
|
* Humanize setting IDs by removing technical prefixes and formatting
|
|
*/
|
|
export function humanizeSettingId(settingId: string): string {
|
|
if (!settingId) return settingId;
|
|
|
|
// Remove common technical prefixes
|
|
let humanized = settingId
|
|
.replace(/^device_vendor_msft_policy_config_/i, '')
|
|
.replace(/^device_vendor_msft_/i, '')
|
|
.replace(/^vendor_msft_policy_config_/i, '')
|
|
.replace(/^admx_/i, '')
|
|
.replace(/^msft_/i, '');
|
|
|
|
// Replace underscores with spaces
|
|
humanized = humanized.replace(/_/g, ' ');
|
|
|
|
// Convert camelCase to space-separated
|
|
humanized = humanized.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
|
|
// Capitalize first letter of each word
|
|
humanized = humanized
|
|
.split(' ')
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
.join(' ');
|
|
|
|
return humanized.trim();
|
|
}
|
|
|
|
export default humanizeSettingId;
|