Skip to content

Commit

Permalink
Fixed mixed tabs/spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
yallie committed Nov 21, 2018
1 parent aedbade commit 3445c02
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
18 changes: 9 additions & 9 deletions Genuine Channels/Sources/GenuineUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ public static string SplitToHostAndPort(string url, out int port)
{
port = 0;

if (string.IsNullOrEmpty(url))
return null;

Uri parsed;
if (Uri.TryCreate(url, UriKind.Absolute, out parsed))
{
port = parsed.IsDefaultPort ? 0 : parsed.Port;
return parsed.DnsSafeHost.Replace("%25", "%").TrimStart('[').TrimEnd(']');
}
if (string.IsNullOrEmpty(url))
return null;

Uri parsed;
if (Uri.TryCreate(url, UriKind.Absolute, out parsed))
{
port = parsed.IsDefaultPort ? 0 : parsed.Port;
return parsed.DnsSafeHost.Replace("%25", "%").TrimStart('[').TrimEnd(']');
}

Match match = _UrlToHost.Match(url);
if (!match.Success)
Expand Down
50 changes: 25 additions & 25 deletions Genuine Channels/Tests/UnitTests/GenuineUtilityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,32 +70,32 @@ public void SplitToHostAndPort_IPv6()
RunSplitToHostAndPortWithInputDictionary(testDict);
}

[TestMethod,Description("Tests with Uris build using the .NET UriBuilder")]
public void SplitToHostAndPort_IPv6_UriSyntax()
{
// as described in RFC 6874 (https://tools.ietf.org/html/rfc6874):
// Used within a URI, a literal IPv6 address is always embedded between "[" and "]"
// Zone IDs have to be URL encoded ("%" ==> "%25").
var testDict = new Dictionary<string, Tuple<string, int>>
{
{ "gtcp://[::1]:1233", new Tuple<string, int>("::1", 1233)},
{ "gtcp://[fec0:0:0:ffff::1]:1234", new Tuple<string, int>("fec0:0:0:ffff::1", 1234)},
{ "gtcp://[fec0:0:0:ffff::1%251]:1235", new Tuple<string, int>("fec0:0:0:ffff::1%1", 1235)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]:1236", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 1236)},
{ "gtcp://[::1]", new Tuple<string, int>("::1", 0)},
{ "gtcp://[fec0:0:0:ffff::1%251]", new Tuple<string, int>("fec0:0:0:ffff::1%1", 0)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 0)},
{ "gtcp://[::1]:1233/subdomain", new Tuple<string, int>("::1", 1233)},
{ "gtcp://[fec0:0:0:ffff::1]:1234/a/b/c", new Tuple<string, int>("fec0:0:0:ffff::1", 1234)},
{ "gtcp://[fec0:0:0:ffff::1%251]:1235/index.rem", new Tuple<string, int>("fec0:0:0:ffff::1%1", 1235)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]:1236/service", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 1236)},
{ "gtcp://[::1]/myservices", new Tuple<string, int>("::1", 0)},
{ "gtcp://[fec0:0:0:ffff::1%251]/a/b/c", new Tuple<string, int>("fec0:0:0:ffff::1%1", 0)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]/index.rem", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 0)}
};
[TestMethod, Description("Tests with Uris build using the .NET UriBuilder")]
public void SplitToHostAndPort_IPv6_UriSyntax()
{
// as described in RFC 6874 (https://tools.ietf.org/html/rfc6874):
// Used within a URI, a literal IPv6 address is always embedded between "[" and "]"
// Zone IDs have to be URL encoded ("%" ==> "%25").
var testDict = new Dictionary<string, Tuple<string, int>>
{
{ "gtcp://[::1]:1233", new Tuple<string, int>("::1", 1233)},
{ "gtcp://[fec0:0:0:ffff::1]:1234", new Tuple<string, int>("fec0:0:0:ffff::1", 1234)},
{ "gtcp://[fec0:0:0:ffff::1%251]:1235", new Tuple<string, int>("fec0:0:0:ffff::1%1", 1235)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]:1236", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 1236)},
{ "gtcp://[::1]", new Tuple<string, int>("::1", 0)},
{ "gtcp://[fec0:0:0:ffff::1%251]", new Tuple<string, int>("fec0:0:0:ffff::1%1", 0)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 0)},
{ "gtcp://[::1]:1233/subdomain", new Tuple<string, int>("::1", 1233)},
{ "gtcp://[fec0:0:0:ffff::1]:1234/a/b/c", new Tuple<string, int>("fec0:0:0:ffff::1", 1234)},
{ "gtcp://[fec0:0:0:ffff::1%251]:1235/index.rem", new Tuple<string, int>("fec0:0:0:ffff::1%1", 1235)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]:1236/service", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 1236)},
{ "gtcp://[::1]/myservices", new Tuple<string, int>("::1", 0)},
{ "gtcp://[fec0:0:0:ffff::1%251]/a/b/c", new Tuple<string, int>("fec0:0:0:ffff::1%1", 0)},
{ "gtcp://[fe80::1d2b:147c:c69a:26ef%2530]/index.rem", new Tuple<string, int>("fe80::1d2b:147c:c69a:26ef%30", 0)}
};

RunSplitToHostAndPortWithInputDictionary(testDict);
}
RunSplitToHostAndPortWithInputDictionary(testDict);
}

private static void RunSplitToHostAndPortWithInputDictionary(Dictionary<string, Tuple<string, int>> testDict)
{
Expand Down

0 comments on commit 3445c02

Please sign in to comment.