Route arguments are now automatically url decoded by the RouteMatcher. Added a unit test to cover this case. Bumped package version to 1.1.8

This commit is contained in:
MattMo 2023-02-02 16:14:32 -08:00
parent 023654aba2
commit f8704e425b
3 changed files with 11 additions and 2 deletions

View File

@ -69,6 +69,14 @@ namespace MontoyaTech.Rest.Net.Tests
arguments[1].Should().Be("2");
}
[Fact]
public void SyntaxWithArgumentsUrlEncodedShouldDecode()
{
RouteMatcher.Matches("http://localhost/a/b%20c", "/a/{name}", out string[] arguments).Should().BeTrue();
arguments.Length.Should().Be(1);
arguments[0].Should().Be("b c");
}
[Fact]
public void SyntaxWithWildcardShouldMatch()
{

View File

@ -17,7 +17,7 @@
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Version>1.1.7</Version>
<Version>1.1.8</Version>
<PackageReleaseNotes></PackageReleaseNotes>
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
</PropertyGroup>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
namespace MontoyaTech.Rest.Net
{
@ -121,7 +122,7 @@ namespace MontoyaTech.Rest.Net
}
else if (condition.StartsWith("{") && condition.EndsWith("}"))
{
arguments[argumentIndex++] = urlSegment;
arguments[argumentIndex++] = WebUtility.UrlDecode(urlSegment);
match = true;
}