mirror of
https://github.com/home-assistant/android
synced 2024-10-15 12:32:54 +00:00
Prevent entity ID typos throwing errors (#3829)
Prevent typos throwing errors for more info panel
This commit is contained in:
parent
02160c4f48
commit
a9b7dfdb68
|
@ -1034,7 +1034,10 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi
|
|||
val path = intent.getStringExtra(EXTRA_PATH)
|
||||
presenter.onViewReady(path)
|
||||
if (path?.startsWith("entityId:") == true) {
|
||||
moreInfoEntity = path.substringAfter("entityId:")
|
||||
// Get the entity ID from a string formatted "entityId:domain.entity"
|
||||
// https://github.com/home-assistant/core/blob/dev/homeassistant/core.py#L159
|
||||
val pattern = "(?<=^entityId:)((?!.+__)(?!_)[\\da-z_]+(?<!_)\\.(?!_)[\\da-z_]+(?<!_)$)".toRegex()
|
||||
moreInfoEntity = pattern.find(path)?.value ?: ""
|
||||
}
|
||||
intent.removeExtra(EXTRA_PATH)
|
||||
|
||||
|
|
Loading…
Reference in a new issue