mirror of https://github.com/jellyfin/jellyfin.git
Fix baseurl (again)
This commit is contained in:
parent
d756233f62
commit
5994328903
|
@ -103,14 +103,11 @@ using MediaBrowser.Providers.Subtitles;
|
||||||
using MediaBrowser.Providers.TV.TheTVDB;
|
using MediaBrowser.Providers.TV.TheTVDB;
|
||||||
using MediaBrowser.WebDashboard.Api;
|
using MediaBrowser.WebDashboard.Api;
|
||||||
using MediaBrowser.XbmcMetadata.Providers;
|
using MediaBrowser.XbmcMetadata.Providers;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Extensions;
|
using Microsoft.AspNetCore.Http.Extensions;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations
|
namespace Emby.Server.Implementations
|
||||||
|
@ -1478,7 +1475,7 @@ namespace Emby.Server.Implementations
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="address">The IPv6 address.</param>
|
/// <param name="address">The IPv6 address.</param>
|
||||||
/// <returns>The IPv6 address without the scope id.</returns>
|
/// <returns>The IPv6 address without the scope id.</returns>
|
||||||
private string RemoveScopeId(string address)
|
private ReadOnlySpan<char> RemoveScopeId(ReadOnlySpan<char> address)
|
||||||
{
|
{
|
||||||
var index = address.IndexOf('%');
|
var index = address.IndexOf('%');
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
|
@ -1486,33 +1483,50 @@ namespace Emby.Server.Implementations
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
return address.Substring(0, index);
|
return address.Slice(0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
public string GetLocalApiUrl(IPAddress ipAddress)
|
public string GetLocalApiUrl(IPAddress ipAddress)
|
||||||
{
|
{
|
||||||
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
{
|
{
|
||||||
var str = RemoveScopeId(ipAddress.ToString());
|
var str = RemoveScopeId(ipAddress.ToString());
|
||||||
|
Span<char> span = new char[str.Length + 2];
|
||||||
|
span[0] = '[';
|
||||||
|
str.CopyTo(span.Slice(1));
|
||||||
|
span[^1] = ']';
|
||||||
|
|
||||||
return GetLocalApiUrl("[" + str + "]");
|
return GetLocalApiUrl(span);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetLocalApiUrl(ipAddress.ToString());
|
return GetLocalApiUrl(ipAddress.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLocalApiUrl(string host)
|
/// <inheritdoc />
|
||||||
|
public string GetLocalApiUrl(ReadOnlySpan<char> host)
|
||||||
{
|
{
|
||||||
|
var url = new StringBuilder(64);
|
||||||
if (EnableHttps)
|
if (EnableHttps)
|
||||||
{
|
{
|
||||||
return string.Format("https://{0}:{1}",
|
url.Append("https://");
|
||||||
host,
|
}
|
||||||
HttpsPort.ToString(CultureInfo.InvariantCulture));
|
else
|
||||||
|
{
|
||||||
|
url.Append("http://");
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Format("http://{0}:{1}",
|
url.Append(host)
|
||||||
host,
|
.Append(':')
|
||||||
HttpPort.ToString(CultureInfo.InvariantCulture));
|
.Append(HttpPort);
|
||||||
|
|
||||||
|
string baseUrl = ServerConfigurationManager.Configuration.BaseUrl;
|
||||||
|
if (baseUrl.Length != 0)
|
||||||
|
{
|
||||||
|
url.Append('/').Append(baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return url.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
public Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
||||||
|
|
|
@ -71,13 +71,15 @@ namespace MediaBrowser.Controller
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the local API URL.
|
/// Gets the local API URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="host">The host.</param>
|
/// <param name="hostname">The hostname.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>The local API URL.</returns>
|
||||||
string GetLocalApiUrl(string host);
|
string GetLocalApiUrl(ReadOnlySpan<char> hostname);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the local API URL.
|
/// Gets the local API URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="address">The IP address.</param>
|
||||||
|
/// <returns>The local API URL.</returns>
|
||||||
string GetLocalApiUrl(IPAddress address);
|
string GetLocalApiUrl(IPAddress address);
|
||||||
|
|
||||||
void LaunchUrl(string url);
|
void LaunchUrl(string url);
|
||||||
|
|
Loading…
Reference in New Issue