From b6daaf6aaa29e20d539e5228604c1a07894c884c Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 12 Jun 2022 23:44:01 +0200 Subject: [PATCH] Fix Uri scheme --- src/Kyoo.Abstractions/Models/Page.cs | 16 ++++++++-------- src/Kyoo.Core/Views/Helper/BaseApi.cs | 2 +- .../Helper/Serializers/JsonSerializerContract.cs | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Kyoo.Abstractions/Models/Page.cs b/src/Kyoo.Abstractions/Models/Page.cs index 848a4e21..0acdb4a9 100644 --- a/src/Kyoo.Abstractions/Models/Page.cs +++ b/src/Kyoo.Abstractions/Models/Page.cs @@ -33,17 +33,17 @@ namespace Kyoo.Abstractions.Models /// /// The link of the current page. /// - public Uri This { get; } + public string This { get; } /// /// The link of the first page. /// - public Uri First { get; } + public string First { get; } /// /// The link of the next page. /// - public Uri Next { get; } + public string Next { get; } /// /// The number of items in the current page. @@ -62,7 +62,7 @@ namespace Kyoo.Abstractions.Models /// The link of the current page. /// The link of the next page. /// The link of the first page. - public Page(ICollection items, Uri @this, Uri next, Uri first) + public Page(ICollection items, string @this, string next, string first) { Items = items; This = @this; @@ -78,21 +78,21 @@ namespace Kyoo.Abstractions.Models /// The list of query strings of the current page /// The number of items requested for the current page. public Page(ICollection items, - Uri url, + string url, Dictionary query, int limit) { Items = items; - This = new Uri(url + query.ToQueryString()); + This = url + query.ToQueryString(); if (items.Count == limit && limit > 0) { query["afterID"] = items.Last().ID.ToString(); - Next = new Uri(url + query.ToQueryString()); + Next = url + query.ToQueryString(); } query.Remove("afterID"); - First = new Uri(url + query.ToQueryString()); + First = url + query.ToQueryString(); } } } diff --git a/src/Kyoo.Core/Views/Helper/BaseApi.cs b/src/Kyoo.Core/Views/Helper/BaseApi.cs index 4a55cfd9..70304719 100644 --- a/src/Kyoo.Core/Views/Helper/BaseApi.cs +++ b/src/Kyoo.Core/Views/Helper/BaseApi.cs @@ -44,7 +44,7 @@ namespace Kyoo.Core.Api { return new Page( resources, - new Uri(Request.Path), + Request.Path, Request.Query.ToDictionary( x => x.Key, x => x.Value.ToString(), diff --git a/src/Kyoo.Core/Views/Helper/Serializers/JsonSerializerContract.cs b/src/Kyoo.Core/Views/Helper/Serializers/JsonSerializerContract.cs index a309478f..a1394b87 100644 --- a/src/Kyoo.Core/Views/Helper/Serializers/JsonSerializerContract.cs +++ b/src/Kyoo.Core/Views/Helper/Serializers/JsonSerializerContract.cs @@ -144,8 +144,7 @@ namespace Kyoo.Core.Api string type = target is ICustomTypeDescriptor descriptor ? descriptor.GetClassName() : target.GetType().Name; - return new Uri($"/{type}/{slug}/{Images.ImageName[_imageIndex]}".ToLowerInvariant()) - .ToString(); + return $"/{type}/{slug}/{Images.ImageName[_imageIndex]}".ToLowerInvariant(); } } }