fix(theme): null/whitespace-safe NavRailSection slug + edge tests

This commit is contained in:
Joseph Doherty
2026-06-03 02:57:07 -04:00
parent e2749b7d69
commit 6aa2ee8095
2 changed files with 20 additions and 1 deletions
@@ -31,8 +31,9 @@
private string ResolvedKey => string.IsNullOrWhiteSpace(Key) ? Slug(Title) : Key!;
private static string Slug(string s)
private static string Slug(string? s)
{
if (string.IsNullOrWhiteSpace(s)) return string.Empty;
var chars = s.Trim().ToLowerInvariant()
.Select(c => char.IsLetterOrDigit(c) ? c : '-').ToArray();
return string.Join('-', new string(chars).Split('-', StringSplitOptions.RemoveEmptyEntries));