diff --git a/ReadSharp.Tests/ReadTests.cs b/ReadSharp.Tests/ReadTests.cs index d4248a2..55183de 100644 --- a/ReadSharp.Tests/ReadTests.cs +++ b/ReadSharp.Tests/ReadTests.cs @@ -156,6 +156,13 @@ namespace ReadSharp.Tests Assert.Equal(result.NextPage.ToString(), "http://arstechnica.com/apple/2014/01/two-steps-forward-a-review-of-the-2013-mac-pro/2"); } + [Fact] + public async Task AreSinglepageArticlesNotPopulatingNextPage() + { + Article result = await reader.Read(new Uri("http://www.buzzfeed.com/mattlynley/the-16-most-interesting-things-to-come-out-of-bill-gates-qa")); + Assert.Null(result.NextPage); + } + [Fact] public async Task TestCriticalURIs() { @@ -192,6 +199,9 @@ namespace ReadSharp.Tests { Article result = await reader.Read(new Uri("http://www.dgtle.com/article-5682-1.html")); Assert.Contains("http://img.dgtle.com/forum/201402/13/162237x8oumb8i0i0y0087.jpeg!680px", result.Content); + + result = await reader.Read(new Uri("http://m.spiegel.de/spiegelgeschichte/a-946060.html")); + Assert.DoesNotContain("Detecting browser settings", result.Content); } diff --git a/ReadSharp/Reader.cs b/ReadSharp/Reader.cs index 72de4c2..a8338c4 100644 --- a/ReadSharp/Reader.cs +++ b/ReadSharp/Reader.cs @@ -34,6 +34,14 @@ namespace ReadSharp /// protected NReadabilityTranscoder _transcoder; + /// + /// Redirect faulty mobile URIs to desktop equivalents + /// + private static readonly Dictionary _redirectFaultyMobileURIs = new Dictionary + { + { "//m.spiegel.de", "//www.spiegel.de" } + }; + /// @@ -106,12 +114,22 @@ namespace ReadSharp Response response; TranscodingResult transcodingResult; Encoding encoding; + string uriString = uri.OriginalString; if (options == null) { options = ReadOptions.CreateDefault(); } + // replace domain when URI is marked as faulty + foreach (string faultyUri in _redirectFaultyMobileURIs.Keys) + { + if (uriString.Contains(faultyUri)) + { + uri = new Uri(uriString.Replace(faultyUri, _redirectFaultyMobileURIs[faultyUri])); + } + } + // make async request try {