mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Move IPv6 scope id removal logic to it's own function
This commit is contained in:
parent
ddd1a282ea
commit
8270d0cc91
@ -1547,17 +1547,27 @@ namespace Emby.Server.Implementations
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the scope id from IPv6 addresses.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">The IPv6 address.</param>
|
||||||
|
/// <returns>The IPv6 address without the scope id.</returns>
|
||||||
|
private string RemoveScopeId(string address)
|
||||||
|
{
|
||||||
|
var index = address.IndexOf('%');
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
return address.Substring(0, index);
|
||||||
|
}
|
||||||
|
|
||||||
public string GetLocalApiUrl(IPAddress ipAddress)
|
public string GetLocalApiUrl(IPAddress ipAddress)
|
||||||
{
|
{
|
||||||
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
{
|
{
|
||||||
// Remove the scope id from IPv6 addresses
|
var str = RemoveScopeId(ipAddress.ToString());
|
||||||
var str = ipAddress.ToString();
|
|
||||||
var index = str.IndexOf('%');
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
str = str.Substring(0, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetLocalApiUrl("[" + str + "]");
|
return GetLocalApiUrl("[" + str + "]");
|
||||||
}
|
}
|
||||||
@ -1583,13 +1593,7 @@ namespace Emby.Server.Implementations
|
|||||||
{
|
{
|
||||||
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
|
||||||
{
|
{
|
||||||
// Remove the scope id from IPv6 addresses
|
var str = RemoveScopeId(ipAddress.ToString());
|
||||||
var str = ipAddress.ToString();
|
|
||||||
var index = str.IndexOf('%');
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
str = str.Substring(0, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetWanApiUrl("[" + str + "]");
|
return GetWanApiUrl("[" + str + "]");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user