diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/ServerAddress.cs b/src/Microsoft.AspNetCore.Server.Kestrel/ServerAddress.cs index 536492dfb1..ce35ff39ce 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/ServerAddress.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/ServerAddress.cs @@ -78,17 +78,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel int schemeDelimiterStart = url.IndexOf("://", StringComparison.Ordinal); if (schemeDelimiterStart < 0) { - int port; - if (int.TryParse(url, NumberStyles.None, CultureInfo.InvariantCulture, out port)) - { - return new ServerAddress() - { - Scheme = "http", - Host = "+", - Port = port, - PathBase = "/" - }; - } return null; } int schemeDelimiterEnd = schemeDelimiterStart + "://".Length; diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs index 1f5fb0a61c..aa966d8298 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs @@ -97,8 +97,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests // Static port var port1 = GetNextPort(); var port2 = GetNextPort(); - dataset.Add($"{port1}", _ => new[] { $"http://localhost:{port1}/" }); - dataset.Add($"{port1};{port2}", _ => new[] { $"http://localhost:{port1}/", $"http://localhost:{port2}/" }); + + // Ensure multiple addresses can be separated by semicolon + dataset.Add($"http://localhost:{port1};http://localhost:{port2}", + _ => new[] { $"http://localhost:{port1}/", $"http://localhost:{port2}/" }); // Ensure "localhost" and "127.0.0.1" are equivalent dataset.Add($"http://localhost:{port1}", _ => new[] { $"http://localhost:{port1}/", $"http://127.0.0.1:{port1}/" }); @@ -108,7 +110,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests dataset.Add($"http://localhost:{port1}/base/path", _ => new[] { $"http://localhost:{port1}/base/path" }); // Dynamic port - dataset.Add("0", GetTestUrls); dataset.Add("http://localhost:0/", GetTestUrls); dataset.Add($"http://{Dns.GetHostName()}:0/", GetTestUrls); diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressFacts.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressTests.cs similarity index 97% rename from test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressFacts.cs rename to test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressTests.cs index d9beaa05b3..8aa99d1917 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressFacts.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressTests.cs @@ -8,10 +8,11 @@ using Xunit; namespace Microsoft.AspNetCore.Server.KestrelTests { - public class ServerAddressFacts + public class ServerAddressTests { [Theory] [InlineData("")] + [InlineData("5000")] [InlineData("//noscheme")] public void FromUriReturnsNullForSchemelessUrls(string url) { @@ -19,7 +20,6 @@ namespace Microsoft.AspNetCore.Server.KestrelTests } [Theory] - [InlineData("5000", "http", "+", 5000, "/", "http://+:5000/")] [InlineData("://emptyscheme", "", "emptyscheme", 0, "", "://emptyscheme:0")] [InlineData("http://localhost", "http", "localhost", 80, "", "http://localhost:80")] [InlineData("http://www.example.com", "http", "www.example.com", 80, "", "http://www.example.com:80")]