-
Notifications
You must be signed in to change notification settings - Fork 55
Open
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");
}
dvdvorle
Metadata
Metadata
Assignees
Labels
No labels