From c21abd5f215be3d1ec24aaf858cbb99e8c84025c Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Sun, 23 Feb 2014 21:03:55 +0100 Subject: [PATCH] try to normalize URIs retrieved in video array; update tests; --- CHANGELOG.md | 5 +++++ PocketSharp.Tests/AddTests.cs | 2 +- PocketSharp.Tests/GetTests.cs | 2 +- PocketSharp.Tests/StressTests.cs | 7 ------- PocketSharp/Models/PocketAuthor.cs | 2 +- PocketSharp/Models/PocketImage.cs | 2 +- PocketSharp/Models/PocketVideo.cs | 2 +- PocketSharp/Properties/AssemblyInfo.cs | 4 ++-- PocketSharp/Utilities/JsonExtensions.cs | 19 +++++++++++++++++-- 9 files changed, 29 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b248c4..7ff5374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### 3.1.1 (2014-02-23) + +- fix SendActions when sending _add_ requests (fixes #20) +- try to normalize URIs retrieved in video array + ### 3.1.0 (2014-02-07) - Use FullTitle if no other title props are available diff --git a/PocketSharp.Tests/AddTests.cs b/PocketSharp.Tests/AddTests.cs index b980e4d..06d6952 100644 --- a/PocketSharp.Tests/AddTests.cs +++ b/PocketSharp.Tests/AddTests.cs @@ -31,7 +31,7 @@ namespace PocketSharp.Tests PocketItem item = await client.Add(uri); - Assert.Equal(uri, item.Uri); + Assert.NotNull(item); itemsToDelete.Add(item.ID); } diff --git a/PocketSharp.Tests/GetTests.cs b/PocketSharp.Tests/GetTests.cs index 785ac4e..3029ac7 100644 --- a/PocketSharp.Tests/GetTests.cs +++ b/PocketSharp.Tests/GetTests.cs @@ -217,7 +217,7 @@ namespace PocketSharp.Tests await client.Unfavorite(itemToModify); - since = DateTime.UtcNow; + since = DateTime.UtcNow.AddMinutes(-1); await client.Archive(itemToModify); diff --git a/PocketSharp.Tests/StressTests.cs b/PocketSharp.Tests/StressTests.cs index 52cdaf2..20210be 100644 --- a/PocketSharp.Tests/StressTests.cs +++ b/PocketSharp.Tests/StressTests.cs @@ -55,13 +55,6 @@ namespace PocketSharp.Tests Assert.True(items.Count == 5000); } - [Fact] - public async Task AreItemsRetrievedProperlyWithoutLimit() - { - List items = await client.Get(state: State.all); - Assert.True(items.Count > 6000); - } - [Fact] public async Task IsSearchSuccessfullyOnBigList() { diff --git a/PocketSharp/Models/PocketAuthor.cs b/PocketSharp/Models/PocketAuthor.cs index 27585d7..0899907 100644 --- a/PocketSharp/Models/PocketAuthor.cs +++ b/PocketSharp/Models/PocketAuthor.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -using System; using PropertyChanged; +using System; namespace PocketSharp.Models { diff --git a/PocketSharp/Models/PocketImage.cs b/PocketSharp/Models/PocketImage.cs index 8160d1b..b9ce376 100644 --- a/PocketSharp/Models/PocketImage.cs +++ b/PocketSharp/Models/PocketImage.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -using System; using PropertyChanged; +using System; namespace PocketSharp.Models { diff --git a/PocketSharp/Models/PocketVideo.cs b/PocketSharp/Models/PocketVideo.cs index 4cb7247..110366c 100644 --- a/PocketSharp/Models/PocketVideo.cs +++ b/PocketSharp/Models/PocketVideo.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -using System; using PropertyChanged; +using System; namespace PocketSharp.Models { diff --git a/PocketSharp/Properties/AssemblyInfo.cs b/PocketSharp/Properties/AssemblyInfo.cs index 7eefc62..6eb0846 100644 --- a/PocketSharp/Properties/AssemblyInfo.cs +++ b/PocketSharp/Properties/AssemblyInfo.cs @@ -22,5 +22,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.1.0")] -[assembly: AssemblyFileVersion("3.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.1.1")] +[assembly: AssemblyFileVersion("3.1.1")] \ No newline at end of file diff --git a/PocketSharp/Utilities/JsonExtensions.cs b/PocketSharp/Utilities/JsonExtensions.cs index 55e612f..936ab9b 100644 --- a/PocketSharp/Utilities/JsonExtensions.cs +++ b/PocketSharp/Utilities/JsonExtensions.cs @@ -79,9 +79,24 @@ namespace PocketSharp { public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - if (reader.TokenType == JsonToken.String && Uri.IsWellFormedUriString(reader.Value.ToString(), UriKind.Absolute)) + if (reader.TokenType != JsonToken.String) { - return new Uri(reader.Value.ToString()); + return null; + } + + string value = reader.Value.ToString(); + + if (Uri.IsWellFormedUriString(value, UriKind.Absolute)) + { + return new Uri(value); + } + else if (value.StartsWith("//") && Uri.IsWellFormedUriString("http:" + value, UriKind.Absolute)) + { + return new Uri("http:" + value); + } + else if (value.StartsWith("www.") && Uri.IsWellFormedUriString("http://" + value, UriKind.Absolute)) + { + return new Uri("http://" + value); } return null;