Format "IP" and "MAC" attribute names (#9034)

This commit is contained in:
Philip Allgaier 2021-04-29 15:55:51 +02:00 committed by GitHub
parent debcdefc21
commit 0562242043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,6 +122,10 @@ export default hassAttributeUtil;
// Convert from internal snake_case format to user-friendly format
export function formatAttributeName(value: string): string {
value = value.replace(/_/g, " ").replace(/\bid\b/g, "ID");
value = value
.replace(/_/g, " ")
.replace(/\bid\b/g, "ID")
.replace(/\bip\b/g, "IP")
.replace(/\bmac\b/g, "MAC");
return value.charAt(0).toUpperCase() + value.slice(1);
}