Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove query params that match slug

  • Loading branch information...
commit be0fc96257e098aecaac001f681bcd8bcd1773f1 1 parent 6c8a8e9
Antony Denyer authored
View
17 src/SevenDigital.Api.Wrapper.Unit.Tests/EndpointResolution/EndpointResolverTests.cs
@@ -105,5 +105,22 @@ public void should_handle_dashes_and_numbers()
Assert.That(result, Is.StringContaining("something/routevalue"));
}
+ [Test]
+ public void should_remove_parameters_that_match()
+ {
+ var endpointInfo = new EndPointInfo
+ {
+ Uri = "something/{route-66}",
+ Parameters = new Dictionary<string, string>
+ {
+ {"route-66","routevalue"}
+ }
+ };
+
+ var result = _endpointResolver.ConstructEndpoint(endpointInfo);
+
+ Assert.That(result, Is.Not.StringContaining("route-66=routevalue"));
+ }
+
}
}
View
5 src/SevenDigital.Api.Wrapper/EndpointResolution/EndpointResolver.cs
@@ -66,8 +66,9 @@ private string SubstituteRouteParameters(string endpointUri, Dictionary<string,
foreach (var match in result)
{
var key = match.ToString().Remove(match.ToString().Length - 1).Remove(0, 1);
- var value = parameters.First(x => x.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)).Value;
- endpointUri = endpointUri.Replace(match.ToString(), value);
+ var entry = parameters.First(x => x.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase));
+ parameters.Remove(entry.Key);
+ endpointUri = endpointUri.Replace(match.ToString(), entry.Value);
}
return endpointUri.ToLower();
Please sign in to comment.
Something went wrong with that request. Please try again.