Skip to content

Commit

Permalink
don't escape if string is too long #10
Browse files Browse the repository at this point in the history
  • Loading branch information
davetimmins committed Jan 15, 2018
1 parent de141e4 commit e17f823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Anywhere.ArcGIS/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
Expand Down
11 changes: 7 additions & 4 deletions tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Polygon>(new Query("Demographics/ESRI_Census_USA/MapServer/5".AsEndpoint()) { Where = "STATE_NAME = 'Texas'" });
return gateway.Query<Polygon>(new Query(relativeUrl) { Where = where });
});

var features = result.Features.Where(f => f.Geometry.Rings.Any()).ToList();
Expand All @@ -72,6 +74,7 @@ async Task Buffer(PortalGatewayBase gateway, List<Feature<Polygon>> features, Sp
});

Assert.NotNull(featuresBuffered);
Assert.NotNull(featuresBuffered.FirstOrDefault()?.Geometry);
Assert.Equal(featuresCount, featuresBuffered.Count);
}

Expand Down

0 comments on commit e17f823

Please sign in to comment.