dotnet / dotnet/smartcomponents

SmartComboBox not working on a French computer

Open
#48 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
508
Forks
61
PR merge metrics
No merged PRs in 30d

Description

There is a problem in \smartcomponents\src\SmartComponents.AspNetCore\SmartComboBox\SmartComboBoxEndpointRouteBuilderExtensions.cs:
```
var form = httpContext.Request.Form;
if (!(form.TryGetValue("inputValue", out var inputValue) && !string.IsNullOrEmpty(inputValue))
|| !(form.TryGetValue("maxResults", out var maxResultsString) && int.TryParse(maxResultsString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var maxResults))
|| !(form.TryGetValue("similarityThreshold", out var similarityThresholdString) && float.TryParse(similarityThresholdString, NumberStyles.Float, CultureInfo.InvariantCulture, out var similarityThreshold)))
{
return Results.BadRequest("inputValue, maxResults, and similarityThreshold are required");
}

if (maxResults < 1 || maxResults > 100)
{
return Results.BadRequest("maxResults must be less than or equal to 100");
}
```
In Line 38, I had to change the code to make it work on my French PC because similarityThresholdString was "0,5" (with a coma) and this fails in the float.TryParse

Here is the fixed code:

```
var form = httpContext.Request.Form;
if (!(form.TryGetValue("inputValue", out var inputValue) && !string.IsNullOrEmpty(inputValue)))
{
return Results.BadRequest("inputValue is required");
}
if (!(form.TryGetValue("maxResults", out var maxResultsString) && int.TryParse(maxResultsString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var maxResults)) )
{
return Results.BadRequest("maxResults is required");
}
if (!(form.TryGetValue("similarityThreshold", out var similarityThresholdString)))
{
return Results.BadRequest("similarityThreshold is required");
}
var similarityThreshold = float.Parse(similarityThresholdString.ToString().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture);
if (maxResults < 1 || maxResults > 100)
{
return Results.BadRequest("maxResults must be less than or equal to 100");
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.