From 0a71285c631a6ef52ea381c35224f353a618e3fa Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 4 Mar 2018 21:05:50 -0500 Subject: fix broken Nexus mod URLs --- .../Framework/Clients/Nexus/NexusWebScrapeClient.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs') diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs index 1e941e3d..d0597965 100644 --- a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs +++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs @@ -72,7 +72,7 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus } // extract mod info - string url = new UriBuilder(this.Client.BaseClient.BaseAddress) { Path = string.Format(this.ModUrlFormat, id) }.Uri.ToString(); + string url = this.GetModUrl(id); string name = doc.DocumentNode.SelectSingleNode("//h1")?.InnerText.Trim(); string version = doc.DocumentNode.SelectSingleNode("//ul[contains(@class, 'stats')]//li[@class='stat-version']//div[@class='stat']")?.InnerText.Trim(); @@ -89,5 +89,18 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus { this.Client?.Dispose(); } + + + /********* + ** Private methods + *********/ + /// Get the full mod page URL for a given ID. + /// The mod ID. + private string GetModUrl(uint id) + { + UriBuilder builder = new UriBuilder(this.Client.BaseClient.BaseAddress); + builder.Path += string.Format(this.ModUrlFormat, id); + return builder.Uri.ToString(); + } } } -- cgit