aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-07-25 00:23:56 +0200
committerBond_009 <bond.009@outlook.com>2019-07-25 00:23:56 +0200
commit8270d0cc91783c0c8c052b43af0d633edb8b6b04 (patch)
tree83852be0b23af0de7f9c01415c271c463805899c /Emby.Server.Implementations/ApplicationHost.cs
parentddd1a282ea6398ee26d74321338d0445d0a0c796 (diff)
Move IPv6 scope id removal logic to it's own function
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs32
1 files changed, 18 insertions, 14 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index c6ba2326a..ef2f59d30 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -1547,17 +1547,27 @@ namespace Emby.Server.Implementations
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)
{
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
{
- // Remove the scope id from IPv6 addresses
- var str = ipAddress.ToString();
- var index = str.IndexOf('%');
- if (index != -1)
- {
- str = str.Substring(0, index);
- }
+ var str = RemoveScopeId(ipAddress.ToString());
return GetLocalApiUrl("[" + str + "]");
}
@@ -1583,13 +1593,7 @@ namespace Emby.Server.Implementations
{
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
{
- // Remove the scope id from IPv6 addresses
- var str = ipAddress.ToString();
- var index = str.IndexOf('%');
- if (index != -1)
- {
- str = str.Substring(0, index);
- }
+ var str = RemoveScopeId(ipAddress.ToString());
return GetWanApiUrl("[" + str + "]");
}