openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
664 stars 392 forks source link

Singular facet URL provides empty page #9200

Open hangy opened 1 year ago

hangy commented 1 year ago

What

Opening the singular version of a facet URL, for example https://world.openfoodfacts.org/contributor/ instead of https://world.openfoodfacts.org/contributors/ or https://world.openfoodfacts.org/contributor/hangy shows an empty page, which might get downloaded to the user's device.

Steps to reproduce the behavior

  1. Open a singular facet URL like https://world.openfoodfacts.org/contributor/ or https://world.openfoodfacts.org/category/
  2. See that HTTP status is 200 OK, and an empty file is provided for "download" (content-type: text/x-perl)

Expected behavior

The call should probably result in 404 Not Found, and show the normal error page.

aakankshabhende commented 1 year ago

@hangy I would like to work on this issue. Could you please assign me this?

alexgarel commented 1 year ago

Let's do it @aakankshabhende (no need to assign)

It happens in Display.pm in display_tag (but it's very messy).

Also it would be even better to have a redirection from /contributor to /contributors (I think we have the plural singular reference somewhere…) but you can leave it as a TODO comment for now !

hangy commented 1 year ago

Also it would be even better to have a redirection from /contributor to /contributors (I think we have the plural singular reference somewhere…) but you can leave it as a TODO comment for now !

Good idea; https://github.com/openfoodfacts/openfoodfacts-server/blob/546f721bf12fe8d4bf02b5f0bd3310c2c15de6e8/lib/ProductOpener/Lang.pm#L48-L51 could help with translating from singular tag to plural tag.

aakankshabhende commented 1 year ago

Yes, I'll look in to it. Thanks!