Side Nav Redesign (#2310)
This commit is contained in:
parent
5c2ebb87cc
commit
00dddaefae
88 changed files with 5971 additions and 572 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Kavita.Common.Helpers;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Kavita.Common;
|
||||
|
|
@ -214,13 +215,8 @@ public static class Configuration
|
|||
var baseUrl = jsonObj.BaseUrl;
|
||||
if (!string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
baseUrl = !baseUrl.StartsWith('/')
|
||||
? $"/{baseUrl}"
|
||||
: baseUrl;
|
||||
|
||||
baseUrl = !baseUrl.EndsWith('/')
|
||||
? $"{baseUrl}/"
|
||||
: baseUrl;
|
||||
baseUrl = UrlHelper.EnsureStartsWithSlash(baseUrl);
|
||||
baseUrl = UrlHelper.EnsureEndsWithSlash(baseUrl);
|
||||
|
||||
return baseUrl;
|
||||
}
|
||||
|
|
|
|||
41
Kavita.Common/Helpers/UrlHelper.cs
Normal file
41
Kavita.Common/Helpers/UrlHelper.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
namespace Kavita.Common.Helpers;
|
||||
|
||||
#nullable enable
|
||||
public static class UrlHelper
|
||||
{
|
||||
public static bool StartsWithHttpOrHttps(string? url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return false;
|
||||
return url.StartsWith("http://") || url.StartsWith("https://");
|
||||
}
|
||||
|
||||
public static string? EnsureStartsWithHttpOrHttps(string? url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return url;
|
||||
if (!url.StartsWith("http://") && !url.StartsWith("https://"))
|
||||
{
|
||||
// URL doesn't start with "http://" or "https://", so add "http://"
|
||||
return "http://" + url;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public static string? EnsureEndsWithSlash(string? url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return url;
|
||||
|
||||
return !url.EndsWith('/')
|
||||
? $"{url}/"
|
||||
: url;
|
||||
|
||||
}
|
||||
|
||||
public static string? EnsureStartsWithSlash(string? url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return url;
|
||||
return !url.StartsWith('/')
|
||||
? $"/{url}"
|
||||
: url;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue