From 0f95f26c1cf69878333e7864d608fb81ea96e080 Mon Sep 17 00:00:00 2001 From: celine Date: Sat, 1 Nov 2025 22:47:05 +0100 Subject: [PATCH] Implemented match group instead of tinkering with the URL string We're using regex already anyways, so might as well take advantage of matching groups. Group 1 will always be the country code and group 2 always the ID --- .../LightlessSyncServices/Discord/MareWizardModule.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.cs b/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.cs index f3ec5a0..5f46000 100644 --- a/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.cs +++ b/LightlessSyncServer/LightlessSyncServices/Discord/MareWizardModule.cs @@ -329,13 +329,12 @@ public partial class LightlessWizardModule : InteractionModuleBase private int? ParseCharacterIdFromLodestoneUrl(string lodestoneUrl) { - var regex = new Regex(@"^https:\/\/(na|eu|de|fr|jp)\.finalfantasyxiv\.com\/lodestone\/character\/\d{8}/?$"); + var regex = new Regex(@"^https:\/\/(na|eu|de|fr|jp)\.finalfantasyxiv\.com\/lodestone\/character\/(\d{8})/?$"); var matches = regex.Match(lodestoneUrl); var isLodestoneUrl = matches.Success; if (!isLodestoneUrl || matches.Groups.Count < 1) return null; + var stringId = matches.Groups[2].ToString(); - lodestoneUrl = matches.Groups[0].ToString(); - var stringId = lodestoneUrl.Split('/', StringSplitOptions.RemoveEmptyEntries).Last(); if (!int.TryParse(stringId, out int lodestoneId)) { return null;