Skip to content

Commit

Permalink
Issue #81: Fix case insensitivity bug
Browse files Browse the repository at this point in the history
    - When the URL template contains query parameters with upper case first letters and the QueryParameters contains them in lowerCase (because they are added using x.Name.ToFirstCharacterLowerCase()) then the names are not matched and the resulting URI does not contain the parameters.
    - When in the URI getter the parameters are actually set using uriTemplate.SetParameter then in the dictionary the casing does not match, and therefore they are silently failing to be set.
    - The UriTemplate ctor contains the optional setting (caseInsensitiveParameterNames) to use a case insensitive dictionary. IMHO this is the best solution because then it does not matter what kind of casing patterns the API models have.
  • Loading branch information
ichbinsteffen committed Jun 29, 2023
1 parent a1f71a8 commit b04d492
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/RequestInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class RequestInformation
if(UrlTemplate?.IndexOf("{+baseurl}", StringComparison.OrdinalIgnoreCase) >= 0 && !PathParameters.ContainsKey("baseurl"))
throw new InvalidOperationException($"{nameof(PathParameters)} must contain a value for \"baseurl\" for the url to be built.");

var parsedUrlTemplate = new UriTemplate(UrlTemplate);
var parsedUrlTemplate = new UriTemplate(UrlTemplate, caseInsensitiveParameterNames: true);
foreach(var urlTemplateParameter in PathParameters)
{
parsedUrlTemplate.SetParameter(urlTemplateParameter.Key, GetSanitizedValue(urlTemplateParameter.Value));
Expand Down

0 comments on commit b04d492

Please sign in to comment.