Skip to content

Fix: array @type parsing - iterate over $type not $types#8

Open
omiba wants to merge 1 commit intobrick:masterfrom
omiba:master
Open

Fix: array @type parsing - iterate over $type not $types#8
omiba wants to merge 1 commit intobrick:masterfrom
omiba:master

Conversation

@omiba
Copy link

@omiba omiba commented Feb 5, 2026

Summary

  • Fixes bug where array-style @type values (e.g., ["Recipe", "NewsArticle"]) were not being parsed
  • The bug was on line 154 where $types (empty array) was used instead of $type (the actual array)

Problem

When parsing JSON-LD with array-style @type like:

{
  "@context": "http://schema.org",
  "@type": ["Recipe", "NewsArticle"],
  "name": "Good Old-Fashioned Pancakes"
}

The library would return an item with no types because line 154 iterated over $types (an empty array initialized on line 143) instead of $type (the array from the JSON).

This affects major recipe sites like AllRecipes.com which use array-style @type values.

Fix

Changed line 154 from:

$types,

to:

$type,

Also renamed the closure parameter from $type to $t to avoid shadowing the outer $type variable.

Test plan

  • Verified fix parses AllRecipes.com recipe pages correctly
  • Array-style @type values are now properly resolved

🤖 Generated with Claude Code

When @type is an array (e.g., ["Recipe", "NewsArticle"]), the code
was incorrectly iterating over $types (empty array) instead of $type
(the actual array of types from the JSON).

This caused pages like AllRecipes.com to fail parsing because they
use array-style @type values.
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.

1 participant