This commit is contained in:
bob
2026-06-02 13:31:27 -05:00
parent 15310f0fd0
commit edc649fc36
33 changed files with 6407 additions and 8 deletions

View File

@@ -27,6 +27,13 @@ public static class SkinLandSlug
/// Lowercase, collapse every run of non-alphanumeric characters to a single hyphen,
/// and trim leading/trailing hyphens. So "AK-47 | Redline (Field-Tested)" and the
/// catalogue's "AK-47 Redline Field-Tested" both reduce to "ak-47-redline-field-tested".
/// <para>
/// The apostrophe is the one exception: skin.land keeps it literally in the slug rather
/// than collapsing it to a hyphen (verified live — "AWP | Man-o'-war" →
/// <c>awp-man-o'-war</c>, "AUG | Lil' Pig" → <c>aug-lil'-pig</c>; the collapsed
/// <c>man-o-war</c>/<c>lil-pig</c> forms 404). Both the ASCII (') and typographic ()
/// apostrophe normalize to a literal ASCII apostrophe in the slug.
/// </para>
/// </summary>
public static string Slugify(string value)
{
@@ -34,7 +41,14 @@ public static class SkinLandSlug
var pendingHyphen = false;
foreach (var ch in value)
{
if (char.IsLetterOrDigit(ch))
if (ch is '\'' or '')
{
// skin.land preserves the apostrophe as part of the word — emit it literally,
// and don't let it trigger a hyphen on either side.
sb.Append('\'');
pendingHyphen = false;
}
else if (char.IsLetterOrDigit(ch))
{
if (pendingHyphen && sb.Length > 0)
{