Slugify title for url (#5621)

This commit is contained in:
Zack Arnett 2020-04-24 10:59:38 -04:00 committed by GitHub
parent bf888b1547
commit db2dab8227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import {
import { createCloseHeading } from "../../../../components/ha-dialog";
import "../../../../components/ha-icon-input";
import { HaSwitch } from "../../../../components/ha-switch";
import { slugify } from "../../../../common/string/slugify";
import {
LovelaceDashboard,
LovelaceDashboardCreateParams,
@ -230,10 +231,11 @@ export class DialogLovelaceDashboardDetail extends LitElement {
if ((this.hass.userData?.showAdvanced && this._urlPath) || !this._title) {
return;
}
const parts = this._title.toLowerCase().split(" ");
this._urlPath =
parts.length === 1 ? `lovelace-${parts[0]}` : parts.join("_");
const slugifyTitle = slugify(this._title);
this._urlPath = slugifyTitle.includes("-")
? slugifyTitle
: `lovelace-${slugifyTitle}`;
}
private _showSidebarChanged(ev: Event) {