Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 5c88a2e

Browse files
Fix navbar being incorrect when following redirect
1 parent 29be8d3 commit 5c88a2e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Home/Components/Navbar.razor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Text.RegularExpressions;
12
using Microsoft.AspNetCore.Components;
23
using Microsoft.AspNetCore.Components.Web;
34

@@ -54,13 +55,17 @@ protected void NavigateToGames()
5455
NavManager.NavigateTo("/games");
5556
}
5657

58+
// For legacy blog URLs, /{Year}/{Month}/{Day}/{Slug}
59+
[GeneratedRegex(@"/\d{4}/\d{2}/\d{2}/[a-zA-Z0-9-]+")]
60+
private static partial Regex LegacyBlogPostUrlRegex();
61+
5762
private void SetSelectedNavButton()
5863
{
59-
if (NavManager.Uri.Contains("/blog"))
64+
if (NavManager.Uri.Contains("/blog") || LegacyBlogPostUrlRegex().IsMatch(NavManager.Uri))
6065
{
6166
SelectedNavButton = NavButton.Blog;
6267
}
63-
else if (NavManager.Uri.Contains("/games"))
68+
else if (NavManager.Uri.Contains("/games")) // Legacy games don't use this navbar so they don't matter
6469
{
6570
SelectedNavButton = NavButton.Games;
6671
}

0 commit comments

Comments
 (0)