From 85479ccd875943e44fa89cde9afce17d82e7c79b Mon Sep 17 00:00:00 2001 From: jweber Date: Mon, 7 Dec 2015 08:39:56 -0800 Subject: [PATCH] Re-adding UriInfo code from before commit 5b0bd6c. UriInfo class was not respecting the URI port and would throw an ArgumentOutOfRangeException if no querystring was defined. --- src/Elasticsearch.Net/Purify/Purify.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Elasticsearch.Net/Purify/Purify.cs b/src/Elasticsearch.Net/Purify/Purify.cs index b4476bfd288..a413c54cd98 100644 --- a/src/Elasticsearch.Net/Purify/Purify.cs +++ b/src/Elasticsearch.Net/Purify/Purify.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Reflection; namespace Purify @@ -180,8 +181,20 @@ public UriInfo(Uri uri, string source) var pathEnd = queryPos == -1 ? fragPos : queryPos; if (pathEnd == -1) pathEnd = source.Length + 1; + + if (start < pathEnd - 1 && source[start] == ':') + { + var portLength = uri.Port.ToString(CultureInfo.InvariantCulture).Length; + start += portLength + 1; + } + Path = queryPos > -1 ? source.Substring(start, pathEnd - start) : source.Substring(start); - Query = fragPos > -1 ? source.Substring(queryPos, fragPos - queryPos) : source.Substring(queryPos); + + Query = fragPos > -1 + ? source.Substring(queryPos, fragPos - queryPos) + : queryPos > -1 + ? source.Substring(queryPos, (source.Length - queryPos)) + : null; } } }