mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Fix extra whitespace in slot slugs (#938)
* Fix extra whitespace in slot slugs * Add slug route parameter to slot and user pages
This commit is contained in:
parent
cac91ff2e1
commit
3c76dfa434
3 changed files with 3 additions and 3 deletions
|
@ -18,7 +18,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("slot/{id:int}")]
|
[Route("slot/{id:int}/{slug?}")]
|
||||||
public class SlotPageController : ControllerBase
|
public class SlotPageController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly DatabaseContext database;
|
private readonly DatabaseContext database;
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("user/{id:int}")]
|
[Route("user/{id:int}/{slug?}")]
|
||||||
public class UserPageController : ControllerBase
|
public class UserPageController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly DatabaseContext database;
|
private readonly DatabaseContext database;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public static partial class SlugExtensions
|
||||||
public static string GenerateSlug(this SlotEntity slot) =>
|
public static string GenerateSlug(this SlotEntity slot) =>
|
||||||
slot.Name.Length == 0
|
slot.Name.Length == 0
|
||||||
? "unnamed-level"
|
? "unnamed-level"
|
||||||
: WhitespaceRegex().Replace(ValidSlugCharactersRegex().Replace(HttpUtility.HtmlDecode(slot.Name), ""), " ").Replace(" ", "-").ToLower();
|
: WhitespaceRegex().Replace(ValidSlugCharactersRegex().Replace(HttpUtility.HtmlDecode(slot.Name), ""), " ").Trim().Replace(" ", "-").ToLower();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a URL slug for the given user
|
/// Generates a URL slug for the given user
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue