Require hyphen in lovelace dashboard url path (#5214)

* Require hyphen in url path

* Update dialog-lovelace-dashboard-detail.ts
This commit is contained in:
Bram Kragten 2020-03-16 12:22:21 +01:00 committed by GitHub
parent 5a84e34f93
commit 447d4604c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -57,7 +57,7 @@ export class DialogLovelaceDashboardDetail extends LitElement {
if (!this._params) { if (!this._params) {
return html``; return html``;
} }
const urlInvalid = !/^[a-zA-Z0-9_-]+$/.test(this._urlPath); const urlInvalid = !/^[a-zA-Z0-9_-]+-[a-zA-Z0-9_-]+$/.test(this._urlPath);
const titleInvalid = !this._urlPath.trim(); const titleInvalid = !this._urlPath.trim();
return html` return html`
<ha-dialog <ha-dialog
@ -215,14 +215,13 @@ export class DialogLovelaceDashboardDetail extends LitElement {
} }
private _fillUrlPath() { private _fillUrlPath() {
if (this._urlPath) { if (this._urlPath || !this._title) {
return; return;
} }
const parts = this._title.split(" "); const parts = this._title.toLowerCase().split(" ");
if (parts.length) { this._urlPath =
this._urlPath = parts.join("_").toLowerCase(); parts.length === 1 ? `lovelace-${parts[0]}` : parts.join("_");
}
} }
private _showSidebarChanged(ev: Event) { private _showSidebarChanged(ev: Event) {

View File

@ -887,7 +887,7 @@
"title": "Title", "title": "Title",
"title_required": "Title is required.", "title_required": "Title is required.",
"url": "Url", "url": "Url",
"url_error_msg": "The url can not contain spaces or special characters, except for _ and -", "url_error_msg": "The url should contain a - and can not contain spaces or special characters, except for _ and -",
"require_admin": "Admin only", "require_admin": "Admin only",
"delete": "Delete", "delete": "Delete",
"update": "Update", "update": "Update",