Skip to content

Commit

Permalink
#92 Fixed a bug that caused URLs containing regular expression reserv…
Browse files Browse the repository at this point in the history
…ed characters to fail the URL matching. Added unit test for the fixed feature. (#93)
  • Loading branch information
rubms authored and hibri committed Jan 26, 2018
1 parent ea71da2 commit a032634
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/HttpMock.Unit.Tests/EndpointMatchingRuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,18 @@ public void should_match_when_the_query_string_has_a_trailing_ampersand()

}

[Test]
public void should_match_urls_containings_regex_reserved_characters()
{
var requestHandler = MockRepository.GenerateStub<IRequestHandler>();
requestHandler.Path = "/test()";
requestHandler.QueryParams = new Dictionary<string, string>();

}
var httpRequestHead = new HttpRequestHead { Uri = "/test()" };
var endpointMatchingRule = new EndpointMatchingRule();
Assert.That(endpointMatchingRule.IsEndpointMatch(requestHandler, httpRequestHead));
}
}


[TestFixture]
Expand Down
2 changes: 1 addition & 1 deletion src/HttpMock/EndpointMatchingRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static bool MatchPath(IRequestHandler requestHandler, HttpRequestHead re
{
pathToMatch = request.Uri.Substring(0, positionOfQueryStart);
}
var pathMatch = new Regex(string.Format(@"^{0}\/*$", requestHandler.Path));
var pathMatch = new Regex(string.Format(@"^{0}\/*$", Regex.Escape(requestHandler.Path)));
return pathMatch.IsMatch(pathToMatch);
}

Expand Down

0 comments on commit a032634

Please sign in to comment.