mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix overview failing to render in some cases with toUpperCase exception (#17021)
This commit is contained in:
parent
e53ae0b333
commit
82463c2ef6
@ -17,12 +17,13 @@ export const stripPrefixFromEntityName = (
|
|||||||
|
|
||||||
if (lowerCasedEntityName.startsWith(lowerCasedPrefixWithSuffix)) {
|
if (lowerCasedEntityName.startsWith(lowerCasedPrefixWithSuffix)) {
|
||||||
const newName = entityName.substring(lowerCasedPrefixWithSuffix.length);
|
const newName = entityName.substring(lowerCasedPrefixWithSuffix.length);
|
||||||
|
if (newName.length) {
|
||||||
// If first word already has an upper case letter (e.g. from brand name)
|
// If first word already has an upper case letter (e.g. from brand name)
|
||||||
// leave as-is, otherwise capitalize the first word.
|
// leave as-is, otherwise capitalize the first word.
|
||||||
return hasUpperCase(newName.substr(0, newName.indexOf(" ")))
|
return hasUpperCase(newName.substr(0, newName.indexOf(" ")))
|
||||||
? newName
|
? newName
|
||||||
: newName[0].toUpperCase() + newName.slice(1);
|
: newName[0].toUpperCase() + newName.slice(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user