From 2dadfc29907034ca5fa20b40fe40d4d2f6e615e1 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 10 Aug 2021 01:29:30 +0200 Subject: [PATCH] Check invariant name of custom listview (#10813) * Check invariant name of custom listview * Update prefix value --- .../components/umblistviewsettings.directive.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umblistviewsettings.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umblistviewsettings.directive.js index 318ffebd1b..d0fd8c7164 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umblistviewsettings.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umblistviewsettings.directive.js @@ -7,8 +7,17 @@ scope.dataType = {}; scope.customListViewCreated = false; + + const listViewPrefix = "List View - "; - const checkForCustomListView = () => scope.dataType.name === "List View - " + scope.modelAlias; + const checkForCustomListView = () => invariantEquals(scope.dataType.name, listViewPrefix + scope.modelAlias); + + // We also use "localeCompare" a few other places. Should probably be moved to a utility/helper function in future. + function invariantEquals(a, b) { + return typeof a === "string" && typeof b === "string" + ? a.localeCompare(b, undefined, { sensitivity: "base" }) === 0 + : a === b; + } /* ---------- INIT ---------- */