Panel_Iframe - Allow relative urls in config (#11832)
* Panel_Iframe - Allow relative urls in config * change regex to check for starting forward slash only * Change error message and const name
This commit is contained in:
parent
74b0740e1c
commit
cad0bde95b
2 changed files with 27 additions and 7 deletions
|
@ -8,22 +8,28 @@ import asyncio
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import (CONF_ICON, CONF_URL)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
DOMAIN = 'panel_iframe'
|
||||
DEPENDENCIES = ['frontend']
|
||||
|
||||
DOMAIN = 'panel_iframe'
|
||||
|
||||
CONF_TITLE = 'title'
|
||||
CONF_ICON = 'icon'
|
||||
CONF_URL = 'url'
|
||||
|
||||
CONF_RELATIVE_URL_ERROR_MSG = "Invalid relative URL. Absolute path required."
|
||||
CONF_RELATIVE_URL_REGEX = r'\A/'
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
DOMAIN: vol.Schema({
|
||||
cv.slug: {
|
||||
vol.Optional(CONF_TITLE): cv.string,
|
||||
vol.Optional(CONF_ICON): cv.icon,
|
||||
# pylint: disable=no-value-for-parameter
|
||||
vol.Required(CONF_URL): vol.Url(),
|
||||
vol.Required(CONF_URL): vol.Any(
|
||||
vol.Match(
|
||||
CONF_RELATIVE_URL_REGEX,
|
||||
msg=CONF_RELATIVE_URL_ERROR_MSG),
|
||||
cv.url),
|
||||
}})}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue