diff --git a/src/Dfe.PlanTech.Application/Extensions/StringExtensions.cs b/src/Dfe.PlanTech.Application/Extensions/StringExtensions.cs index a2920c852..e558debca 100644 --- a/src/Dfe.PlanTech.Application/Extensions/StringExtensions.cs +++ b/src/Dfe.PlanTech.Application/Extensions/StringExtensions.cs @@ -1,7 +1,10 @@ +using System.Net; + namespace Dfe.PlanTech; public static class StringExtensions { + public const string NonBreakingHyphen = "‑"; public static string FirstCharToUpper(this string input) { if (string.IsNullOrEmpty(input)) @@ -12,4 +15,13 @@ public static string FirstCharToUpper(this string input) input.AsSpan(0, 1).ToUpperInvariant(destination); return $"{destination}{input.AsSpan(1)}"; } + + public static string? UseNonBreakingHyphenAndHtmlDecode(this string? text) + { + if (string.IsNullOrEmpty(text)) + { + return text; + } + return WebUtility.HtmlDecode(text.Replace("-", NonBreakingHyphen)); + } } diff --git a/src/Dfe.PlanTech.Web/Models/PageViewModel.cs b/src/Dfe.PlanTech.Web/Models/PageViewModel.cs index a1e76a7d8..5998d41a8 100644 --- a/src/Dfe.PlanTech.Web/Models/PageViewModel.cs +++ b/src/Dfe.PlanTech.Web/Models/PageViewModel.cs @@ -10,7 +10,8 @@ public class PageViewModel public PageViewModel(Page page, Controller controller, IUser user, ILogger logger, bool displayBlueBanner = true) { - controller.ViewData["Title"] = System.Net.WebUtility.HtmlDecode(page.Title?.Text) ?? + + controller.ViewData["Title"] = StringExtensions.UseNonBreakingHyphenAndHtmlDecode(page.Title?.Text) ?? "Plan Technology For Your School"; Page = page; DisplayBlueBanner = displayBlueBanner; diff --git a/src/Dfe.PlanTech.Web/Views/Shared/Components/Title.cshtml b/src/Dfe.PlanTech.Web/Views/Shared/Components/Title.cshtml index 89f96cc08..12980692f 100644 --- a/src/Dfe.PlanTech.Web/Views/Shared/Components/Title.cshtml +++ b/src/Dfe.PlanTech.Web/Views/Shared/Components/Title.cshtml @@ -1,3 +1,4 @@ +@using Dfe.PlanTech @model Dfe.PlanTech.Domain.Content.Models.Title; -