Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: loosing the second facet at the end of the url on redirection #8307

Merged
merged 3 commits into from
Apr 13, 2023

Conversation

jnsereko
Copy link
Contributor

@jnsereko jnsereko commented Apr 10, 2023

What

I have appended $request_ref->{groupby_tagtype} to the $request_ref->{current_link} so that there is no truncation in redirection.
I have also added tests to verify that,

  1. request is processed
  2. the second facet exists in the redirection link

cc @yuktea @alexgarel @stephanegigandet

Screenshot

redirect.new.mov

Related issue(s) and discussion

@@ -150,4 +151,59 @@ $product_ref = {
$expected = lang('to_do_status') . separator_before_colon($lc) . q{:};
like(display_field($product_ref, 'states'), qr/$expected/);

# should not loose the second facet at the end of the url on redirection
my $facets_ref = {
'current_link' => 'category/en:lemonades/data-quality',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current_link will be set by display_tag(), so the value you set here will be overwritten, we can remove it.

we should add a tagtype => "categories" though, otherwise you get a //lemonade/data-quality link, instead of /category/lemonade/data-quality

Can you use "bread" instead of "lemonades"? There's an issue in the categories taxonomy, the canonical name should be in plural (lemonades), but currently it's in singular.


display_tag($facets_ref);

unlike($facets_ref->{'current_link'}, qr/en:lemonades\/data\-quality/); # verify that link has been processed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of like() , unlike(), I think it's best to use is() in order to check the exact value and verify it's the one we expect

e.g. is($facets_ref->{'current_link'}, '/category/bread/data-quality')

@@ -3060,6 +3060,7 @@ sub display_tag ($request_ref) {
}

if (defined $request_ref->{groupby_tagtype}) {
$request_ref->{current_link} .= "/" . $tag_type_plural{$request_ref->{groupby_tagtype}}{$lc};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@stephanegigandet
Copy link
Contributor

Hi @jnsereko , thanks a lot for adding a test with the mock functions. Your fix looks good, and for the test I made some suggestions. Thanks!

@sonarcloud
Copy link

sonarcloud bot commented Apr 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Apr 13, 2023

Please retry analysis of this Pull-Request directly on SonarCloud.

Copy link
Contributor

@stephanegigandet stephanegigandet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you very much @jnsereko !

@stephanegigandet stephanegigandet merged commit 28aa93d into openfoodfacts:main Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect for synonym on facets loose the end of the url
2 participants