From d8330f2362066cce8fea536c0da553d64b1ac8ed Mon Sep 17 00:00:00 2001 From: David Smith Date: Sat, 1 Aug 2015 18:26:43 -0500 Subject: [PATCH] Adjust function to extract post ID from a URL to handle both short-form and long-form formatting. --- TallyCore/Adapters/XenForoAdapter.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TallyCore/Adapters/XenForoAdapter.cs b/TallyCore/Adapters/XenForoAdapter.cs index 375a0f6e..d655e9cd 100644 --- a/TallyCore/Adapters/XenForoAdapter.cs +++ b/TallyCore/Adapters/XenForoAdapter.cs @@ -576,11 +576,18 @@ private string GetPostIdFromUrl(string url) if (url == null) throw new ArgumentNullException(nameof(url)); + // Format: https://forums.sufficientvelocity.com/posts/4062860/ Regex postLinkRegex = new Regex(@"posts/(?\d+)/"); var m = postLinkRegex.Match(url); if (m.Success) return m.Groups["postId"].Value; + // Format: https://forums.sufficientvelocity.com/threads/a-villain-in-a-world-of-heroes.18001/page-109#post-4062860 + postLinkRegex = new Regex(@"/page-\d+#post-(?\d+)"); + m = postLinkRegex.Match(url); + if (m.Success) + return m.Groups["postId"].Value; + throw new ArgumentException("Unable to extract post ID from link:\n" + url, nameof(url)); }