diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b66907..23c5dab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Added extension method for peeking queues + +### Changed + - IcdUriBuilder constructors behave closer to UriBuilder, Host defaults to "localhost" ## [9.3.0] - 2019-04-16 ### Added diff --git a/ICD.Common.Utils.Tests/IcdUriBuilderTest.cs b/ICD.Common.Utils.Tests/IcdUriBuilderTest.cs index 16ebdeb..3baebfa 100644 --- a/ICD.Common.Utils.Tests/IcdUriBuilderTest.cs +++ b/ICD.Common.Utils.Tests/IcdUriBuilderTest.cs @@ -63,14 +63,14 @@ namespace ICD.Common.Utils.Tests #endregion - [TestCase("http://localhost/", null, null, null, null, (ushort)0, null, null, null)] - [TestCase("http://localhost:80/", null, null, null, null, (ushort)80, null, null, null)] - [TestCase("http://username@localhost/", null, null, null, null, (ushort)0, null, null, "username")] - [TestCase("http://localhost/", null, null, "password", null, (ushort)0, null, null, null)] - [TestCase("https://localhost/", null, null, null, null, (ushort)0, null, "https", null)] - [TestCase("http://localhost/test", null, null, null, "test", (ushort)0, null, null, null)] - [TestCase("http://localhost/test", null, null, null, "/test", (ushort)0, null, null, null)] - [TestCase("http://localhost//test", null, null, null, "//test", (ushort)0, null, null, null)] + [TestCase("http:///", null, null, null, null, (ushort)0, null, null, null)] + [TestCase("http://localhost:80/", null, "localhost", null, null, (ushort)80, null, null, null)] + [TestCase("http://username@localhost/", null, "localhost", null, null, (ushort)0, null, null, "username")] + [TestCase("http://localhost/", null, "localhost", "password", null, (ushort)0, null, null, null)] + [TestCase("https://localhost/", null, "localhost", null, null, (ushort)0, null, "https", null)] + [TestCase("http://localhost/test", null, "localhost", null, "test", (ushort)0, null, null, null)] + [TestCase("http://localhost/test", null, "localhost", null, "/test", (ushort)0, null, null, null)] + [TestCase("http://localhost//test", null, "localhost", null, "//test", (ushort)0, null, null, null)] public void ToStringTest(string expected, string fragment, string address, string password, string path, ushort port, string query, string scheme, string userName) { diff --git a/ICD.Common.Utils/IcdUriBuilder.cs b/ICD.Common.Utils/IcdUriBuilder.cs index 4a385f0..15d482f 100644 --- a/ICD.Common.Utils/IcdUriBuilder.cs +++ b/ICD.Common.Utils/IcdUriBuilder.cs @@ -66,7 +66,7 @@ namespace ICD.Common.Utils /// Constructor. /// public IcdUriBuilder() - : this((Uri)null) + : this(new Uri("http://localhost/")) { } @@ -86,7 +86,7 @@ namespace ICD.Common.Utils public IcdUriBuilder(Uri uri) { if (uri == null) - return; + throw new ArgumentNullException("uri"); if (!uri.IsAbsoluteUri) uri = new Uri(Uri.UriSchemeHttp + Uri.SchemeDelimiter + uri); @@ -134,8 +134,7 @@ namespace ICD.Common.Utils builder.Append('@'); } - string host = string.IsNullOrEmpty(Host) ? "localhost" : Host; - builder.Append(host); + builder.Append(Host); if (Port != 0) {