From e17f82344516811ed638eb291863a036012ad016 Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Tue, 16 Jan 2018 07:42:32 +1300 Subject: [PATCH] don't escape if string is too long #10 --- src/Anywhere.ArcGIS/Extensions/StringExtensions.cs | 6 +++++- .../GeometryGatewayTests.cs | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs b/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs index 8573677..eeb6664 100644 --- a/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs +++ b/src/Anywhere.ArcGIS/Extensions/StringExtensions.cs @@ -58,7 +58,11 @@ public static string AsRootUrl(this string rootUrl) public static string UrlEncode(this string text) { - return string.IsNullOrWhiteSpace(text) ? text : Uri.EscapeDataString(text); + return string.IsNullOrWhiteSpace(text) + ? text + : text.Length > 65520 + ? text // this will get sent to POST anyway so don't bother escaping + : Uri.EscapeDataString(text); } /// diff --git a/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs index 7cb7531..921632c 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs @@ -45,14 +45,16 @@ public async Task CanProject() Assert.NotEqual(projectedFeatures[0].Geometry.Rings[0], features[0].Geometry.Rings[0]); } - [Fact] - public async Task CanBuffer() + [Theory] + [InlineData("http://sampleserver1.arcgisonline.com/ArcGIS", "Demographics/ESRI_Census_USA/MapServer/5", "STATE_NAME = 'Texas'")] + [InlineData("https://sampleserver6.arcgisonline.com/arcgis", "WorldTimeZones/MapServer/2", "REGION = 'Southeastern Asia'")] + public async Task CanBuffer(string rootUrl, string relativeUrl, string where) { - var gateway = new PortalGateway("http://sampleserver1.arcgisonline.com/ArcGIS"); + var gateway = new PortalGateway(rootUrl); var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { - return gateway.Query(new Query("Demographics/ESRI_Census_USA/MapServer/5".AsEndpoint()) { Where = "STATE_NAME = 'Texas'" }); + return gateway.Query(new Query(relativeUrl) { Where = where }); }); var features = result.Features.Where(f => f.Geometry.Rings.Any()).ToList(); @@ -72,6 +74,7 @@ async Task Buffer(PortalGatewayBase gateway, List> features, Sp }); Assert.NotNull(featuresBuffered); + Assert.NotNull(featuresBuffered.FirstOrDefault()?.Geometry); Assert.Equal(featuresCount, featuresBuffered.Count); }