From 1ad4414026eef54d9bd6b59503c0b9c41c92b99c Mon Sep 17 00:00:00 2001 From: Mario Lopez Date: Wed, 29 May 2019 11:39:10 +1000 Subject: [PATCH] case insensitive section comparison --- src/Umbraco.Web.UI.Client/src/routes.js | 8 ++++++-- src/Umbraco.Web/Services/SectionService.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/routes.js b/src/Umbraco.Web.UI.Client/src/routes.js index 001888f3ca..e2a2cfe938 100644 --- a/src/Umbraco.Web.UI.Client/src/routes.js +++ b/src/Umbraco.Web.UI.Client/src/routes.js @@ -39,10 +39,14 @@ app.config(function ($routeProvider) { $route.current.params.section = "content"; } + var found = _.find(user.allowedSections, function (s) { + return s.localeCompare($route.current.params.section, undefined, { sensitivity: 'accent' }) === 0; + }) + // U4-5430, Benjamin Howarth // We need to change the current route params if the user only has access to a single section // To do this we need to grab the current user's allowed sections, then reject the promise with the correct path. - if (user.allowedSections.indexOf($route.current.params.section) > -1) { + if (found) { //this will resolve successfully so the route will continue return $q.when(true); } else { @@ -119,7 +123,7 @@ app.config(function ($routeProvider) { sectionService.getSectionsForUser().then(function(sections) { //find the one we're requesting var found = _.find(sections, function(s) { - return s.alias === $routeParams.section; + return s.alias.localeCompare($routeParams.section, undefined, { sensitivity: 'accent' }) === 0; }) if (found && found.routePath) { //there's a custom route path so redirect diff --git a/src/Umbraco.Web/Services/SectionService.cs b/src/Umbraco.Web/Services/SectionService.cs index c001233152..2696186301 100644 --- a/src/Umbraco.Web/Services/SectionService.cs +++ b/src/Umbraco.Web/Services/SectionService.cs @@ -39,6 +39,6 @@ namespace Umbraco.Web.Services /// public ISection GetByAlias(string appAlias) - => GetSections().FirstOrDefault(t => t.Alias == appAlias); + => GetSections().FirstOrDefault(t => t.Alias.Equals(appAlias, StringComparison.OrdinalIgnoreCase)); } }