mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 13:44:33 -04:00
Merge pull request #33 from AnonymusRaccoon/fix
Fixing public url with double '/'
This commit is contained in:
commit
1d114cc91f
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@ -12,17 +13,17 @@ namespace Kyoo.Models
|
||||
/// <summary>
|
||||
/// The link of the current page.
|
||||
/// </summary>
|
||||
public string This { get; }
|
||||
public Uri This { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The link of the first page.
|
||||
/// </summary>
|
||||
public string First { get; }
|
||||
public Uri First { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The link of the next page.
|
||||
/// </summary>
|
||||
public string Next { get; }
|
||||
public Uri Next { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of items in the current page.
|
||||
@ -42,7 +43,7 @@ namespace Kyoo.Models
|
||||
/// <param name="this">The link of the current page.</param>
|
||||
/// <param name="next">The link of the next page.</param>
|
||||
/// <param name="first">The link of the first page.</param>
|
||||
public Page(ICollection<T> items, string @this, string next, string first)
|
||||
public Page(ICollection<T> items, Uri @this, Uri next, Uri first)
|
||||
{
|
||||
Items = items;
|
||||
This = @this;
|
||||
@ -58,21 +59,21 @@ namespace Kyoo.Models
|
||||
/// <param name="query">The list of query strings of the current page</param>
|
||||
/// <param name="limit">The number of items requested for the current page.</param>
|
||||
public Page(ICollection<T> items,
|
||||
string url,
|
||||
Uri url,
|
||||
Dictionary<string, string> query,
|
||||
int limit)
|
||||
{
|
||||
Items = items;
|
||||
This = url + query.ToQueryString();
|
||||
This = new Uri(url + query.ToQueryString());
|
||||
|
||||
if (items.Count == limit && limit > 0)
|
||||
{
|
||||
query["afterID"] = items.Last().ID.ToString();
|
||||
Next = url + query.ToQueryString();
|
||||
Next = new Uri(url + query.ToQueryString());
|
||||
}
|
||||
|
||||
query.Remove("afterID");
|
||||
First = url + query.ToQueryString();
|
||||
First = new Uri(url + query.ToQueryString());
|
||||
}
|
||||
}
|
||||
}
|
@ -15,9 +15,9 @@ namespace Kyoo.CommonApi
|
||||
public class CrudApi<T> : ControllerBase where T : class, IResource
|
||||
{
|
||||
private readonly IRepository<T> _repository;
|
||||
protected readonly string BaseURL;
|
||||
protected readonly Uri BaseURL;
|
||||
|
||||
public CrudApi(IRepository<T> repository, string baseURL)
|
||||
public CrudApi(IRepository<T> repository, Uri baseURL)
|
||||
{
|
||||
_repository = repository;
|
||||
BaseURL = baseURL;
|
||||
@ -82,8 +82,8 @@ namespace Kyoo.CommonApi
|
||||
protected Page<TResult> Page<TResult>(ICollection<TResult> resources, int limit)
|
||||
where TResult : IResource
|
||||
{
|
||||
return new(resources,
|
||||
BaseURL + Request.Path,
|
||||
return new Page<TResult>(resources,
|
||||
new Uri(BaseURL, Request.Path),
|
||||
Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase),
|
||||
limit);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace Kyoo.Models.Options
|
||||
{
|
||||
/// <summary>
|
||||
@ -11,14 +13,14 @@ namespace Kyoo.Models.Options
|
||||
public const string Path = "Basics";
|
||||
|
||||
/// <summary>
|
||||
/// The internal url where the server will listen
|
||||
/// The internal url where the server will listen. It supports globing.
|
||||
/// </summary>
|
||||
public string Url { get; set; } = "http://*:5000";
|
||||
|
||||
/// <summary>
|
||||
/// The public url that will be used in items response and in authentication server host.
|
||||
/// </summary>
|
||||
public string PublicUrl { get; set; } = "http://localhost:5000/";
|
||||
public Uri PublicUrl { get; set; } = new("http://localhost:5000");
|
||||
|
||||
/// <summary>
|
||||
/// The path of the plugin directory.
|
||||
|
@ -20,7 +20,7 @@ namespace Kyoo.Api
|
||||
public class LibraryItemApi : ControllerBase
|
||||
{
|
||||
private readonly ILibraryItemRepository _libraryItems;
|
||||
private readonly string _baseURL;
|
||||
private readonly Uri _baseURL;
|
||||
|
||||
|
||||
public LibraryItemApi(ILibraryItemRepository libraryItems, IOptions<BasicOptions> options)
|
||||
@ -44,7 +44,7 @@ namespace Kyoo.Api
|
||||
new Pagination(limit, afterID));
|
||||
|
||||
return new Page<LibraryItem>(resources,
|
||||
_baseURL + Request.Path,
|
||||
new Uri(_baseURL + Request.Path),
|
||||
Request.Query.ToDictionary(x => x.Key, x => x.Value.ToString(), StringComparer.InvariantCultureIgnoreCase),
|
||||
limit);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user