openfoodfacts/openfoodfacts-ios

Sanitize the barcodes before making a query

teolemon opened this issue · 0 comments

URL is not valid: https://ssl-api.openfoodfacts.org/api/v0/product/ 18 DEC 1988.json?fields=brands,code,ecoscore_alpha,ecoscore_grade,environment_impact_level_tags,image_front_url,image_front_small_url,image_small_url,image_url,nova_group,nutrition_grades,product_name,quantity,states

We could:

  • remove all whitespaces so that the URL is valid (it sends back the proper thing in a web browser: {"status":0,"code":"181988","status_verbose":"product not found"})

We should perhaps be cautious about directly enforcing anything like EAN-8 or EAN-13 (many cases where producers have longer barcodes like in spain)