Open stephanegigandet opened 9 months ago
Can I get to know more about this issue
@himanshisrestha Have you looked at the video?
Hi @anaritadauane , yes I've looked at the video. Thank you
@stephanegigandet , I've refered to the code and found that the related code is in Display.pm around here: `if ((defined $options{product_type}) and ($options{product_type} eq "food")) {
push @{$template_data_ref->{sort_options}},
{
value => "popularity",
link => $request_ref->{current_link} . "?sort_by=popularity",
name => lang("sort_by_popularity")
};
push @{$template_data_ref->{sort_options}},`
and this causes the url to contain the '?' instead of '&' Could you give me some more idea about this to proceed on it
@himanshisrestha Instead of generating an url like https://world.openfoodfacts.org/cgi/search.pl?action=process&search_terms=test&sort_by=unique_scans_n&page_size=24?sort_by=created_t we want to generate an URL like https://world.openfoodfacts.org/cgi/search.pl?action=process&search_terms=test&sort_by=created_t&page_size=24 when the sort button is used on the search results page.
Of course for other pages like the home page, we still want to have URL that work with the search button
@stephanegigandet I we changed the code here and in effect
Could you review this changes and is it that I should make some changes in the test script files (.t) for this ?
@himanshisrestha I think your change is fine, also did you verify it does not break
This way of adding parameter is in my opinion not quite good (we should instead collect parameters in a dict and at the end create the corresponding url parameters) but it would be maybe beyond the scope of this fix.
Maybe adding a method in Web.pm like add_params($url, $params) where you verify if you already have a '?' to decide wether to concatenate $params with a '?' or a '&' would be great and easy to add. (and we could use it ubiquitously)
Regarding tests you could complete current integration test to verify if the links to sort the page as expected are present in page HTML.
What
Resulting url has 2 sort_by fields, with the last one with a ? instead of & :
http://world.openfoodfacts.localhost/cgi/search.pl?action=process&search_terms=coca&sort_by=unique_scans_n&page_size=24?sort_by=last_modified_t
Reported by Olaf Görlitz on Slack: https://openfoodfacts.slack.com/archives/CUZK65DGE/p1700749241876539 (includes video)
Part of
5492