Skip to content

fix(og): map 'foreign beer' category to international-beer API endpoint - #290

Merged
richardthe3rd merged 3 commits into
mainfrom
claude/check-beer-metadata-b4SCN
May 17, 2026
Merged

fix(og): map 'foreign beer' category to international-beer API endpoint#290
richardthe3rd merged 3 commits into
mainfrom
claude/check-beer-metadata-b4SCN

Conversation

@richardthe3rd

Copy link
Copy Markdown
Owner

The OG preview handler derives the API endpoint name directly from the
URL's category param. For foreign beer drinks the category field value
is 'foreign beer' (with a space) but the API endpoint is
'international-beer', so the handler fetched a non-existent URL and
silently fell back to the plain SPA — no OG metadata was injected.

Add a CATEGORY_TO_ENDPOINT lookup in fetchDrinkData so 'foreign beer'
resolves to 'international-beer.json', matching what the Flutter app
uses when loading these drinks.

The OG preview handler derives the API endpoint name directly from the
URL's category param. For foreign beer drinks the category field value
is 'foreign beer' (with a space) but the API endpoint is
'international-beer', so the handler fetched a non-existent URL and
silently fell back to the plain SPA — no OG metadata was injected.

Add a CATEGORY_TO_ENDPOINT lookup in fetchDrinkData so 'foreign beer'
resolves to 'international-beer.json', matching what the Flutter app
uses when loading these drinks.
Copilot AI review requested due to automatic review settings May 17, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes OG metadata generation for foreign beer drink URLs by translating the product category value to the corresponding data API endpoint before fetching preview data.

Changes:

  • Adds a category-to-endpoint mapping for foreign beerinternational-beer.
  • Adds a unit test covering the mapped endpoint URL.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
functions/_lib/drink-preview.js Maps category values to API endpoint names before fetching drink data.
functions/test/drink-preview.test.js Verifies foreign beer fetches international-beer.json.

Comment thread functions/_lib/drink-preview.js Outdated

export async function fetchDrinkData(festivalId, category) {
const url = `${DATA_BASE_URL}/${encodeURIComponent(festivalId)}/${encodeURIComponent(category)}.json`;
const endpoint = CATEGORY_TO_ENDPOINT[category] ?? category;
Using bracket notation on a plain object lets inherited property names
like 'constructor' or '__proto__' resolve to non-string values and
produce a malformed upstream URL. Object.hasOwn checks own properties
only, so unknown categories fall through to the original value safely.
@github-actions

Copy link
Copy Markdown
Contributor

LCOV of commit 264ab85 during CI #222

Summary coverage rate:
  lines......: 77.7% (2482 of 3195 lines)
  functions..: no data found
  branches...: no data found

Files changed coverage rate: n/a

@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@richardthe3rd
richardthe3rd merged commit 606c21a into main May 17, 2026
10 checks passed
@richardthe3rd
richardthe3rd deleted the claude/check-beer-metadata-b4SCN branch May 17, 2026 19:19
This was referenced May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants