diff --git a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsArticleId.cs b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsArticleId.cs index ebd0d0df..ced41489 100644 --- a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsArticleId.cs +++ b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsArticleId.cs @@ -20,7 +20,10 @@ public static bool TryParseUrl(string urlRaw, out TType articleId) if (!url.Host.EndsWith("nexusmods.com")) return false; - if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, _, var articleIdRaw, ..]) + if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, var articles, var articleIdRaw, ..]) + return false; + + if (!string.Equals(articles, "articles", StringComparison.OrdinalIgnoreCase)) return false; return TryParse(articleIdRaw, out articleId); diff --git a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsModId.cs b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsModId.cs index 16c08a82..3fe63989 100644 --- a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsModId.cs +++ b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsModId.cs @@ -20,7 +20,10 @@ public static bool TryParseUrl(string? urlRaw, out TType modId) if (!url.Host.EndsWith("nexusmods.com")) return false; - if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, _, var modIdRaw, ..]) + if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, var mods, var modIdRaw, ..]) + return false; + + if (!string.Equals(mods, "mods", StringComparison.OrdinalIgnoreCase)) return false; return TryParse(modIdRaw, out modId); diff --git a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsUserId.cs b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsUserId.cs index 7160d38b..e51c7ec5 100644 --- a/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsUserId.cs +++ b/src/BUTR.Site.NexusMods.Server.ValueObjects.Vogen/Models/NexusModsUserId.cs @@ -20,9 +20,12 @@ public static bool TryParseUrl(string urlRaw, out TType userId) if (!url.Host.EndsWith("nexusmods.com")) return false; - if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, _, var userIdRaw, ..]) + if (url.LocalPath.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) is not [_, var users, var userIdRaw, ..]) return false; + if (!string.Equals(users, "users", StringComparison.OrdinalIgnoreCase)) + return false; + return TryParse(userIdRaw, out userId); } diff --git a/src/BUTR.Site.NexusMods.Shared/Helpers/NexusModsUtils.cs b/src/BUTR.Site.NexusMods.Shared/Helpers/NexusModsUtils.cs index ac2433bb..610615ad 100644 --- a/src/BUTR.Site.NexusMods.Shared/Helpers/NexusModsUtils.cs +++ b/src/BUTR.Site.NexusMods.Shared/Helpers/NexusModsUtils.cs @@ -23,6 +23,9 @@ public static bool TryParseModUrl(string? url, [NotNullWhen(true)] out string? g var split = str1[1].Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); if (split.Length != 3) return false; + + if (!string.Equals(split[1], "mods", StringComparison.OrdinalIgnoreCase)) + return false; if (!uint.TryParse(split[2], out var modIdNumber)) return false; @@ -51,6 +54,9 @@ public static bool TryParseUserId(string? url, [NotNullWhen(true)] out string? g if (split.Length != 3) return false; + if (!string.Equals(split[1], "users", StringComparison.OrdinalIgnoreCase)) + return false; + if (!uint.TryParse(split[2], out var userIdNumber)) return false;