From 70bae29fa673d93cece0b59b9112ab3373ae002f Mon Sep 17 00:00:00 2001 From: forest93 Date: Mon, 30 Jul 2018 14:43:25 +0800 Subject: [PATCH] Fixed System.ArgumentException for Flow boards without pagination. Accessed JArray values with invalid key value: "fwd". Int32 array index expected. --- WikiClientLibrary.Flow/Board.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/WikiClientLibrary.Flow/Board.cs b/WikiClientLibrary.Flow/Board.cs index d1dee2208..f9db92582 100644 --- a/WikiClientLibrary.Flow/Board.cs +++ b/WikiClientLibrary.Flow/Board.cs @@ -127,7 +127,11 @@ public IAsyncEnumerable EnumTopicsAsync(TopicListingOptions options, int var jresult = await Site.InvokeMediaWikiApiAsync(new MediaWikiFormRequestMessage(queryParams), ct); var jtopiclist = (JObject)jresult["flow"]["view-topiclist"]["result"]["topiclist"]; await sink.YieldAndWait(Topic.FromJsonTopicList(Site, jtopiclist)); - var nextPageUrl = (string)jtopiclist["links"]?["pagination"]?["fwd"]?["url"]; + // 2018-07-30 flow.view-topiclist.result.topiclist.links.pagination is [] instead of null for boards without pagination. + var jpagination = jtopiclist["links"]?["pagination"]; + var nextPageUrl = jpagination == null || jpagination is JArray + ? null + : (string) jpagination["fwd"]?["url"]; if (nextPageUrl != null) { var urlParams = FlowUtility.ParseUrlQueryParametrs(nextPageUrl);