-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
This bit of code is intended to remove h-cards from implicit feeds of h-* when parsing:
Line 36 in a4cda27
| // If there is more than one item on the page, it may be a feed. |
It appears the logic doesn't work quite right if the h-card has no url property. In this example, the parsed mf2 is (snipped out parts not needed for this example):
"items": [
{
"type": [
"h-entry"
],
"properties": {
"url": [],
"published": [],
"author": [],
"like-of": []
},
"lang": "en"
},
{
"type": [
"h-card"
],
"properties": {
"name": [
"RSS \u00b7 Webmentions"
]
},
"lang": "en"
}
],This is a bit more verbose in part to make it easier to follow, but I think the array_filter should be something like:
$tmpmf2 = array_filter($items, function($item) use($url) {
if (!in_array('h-card', $item['type'])) {
// not an h-card; keep it in the result array
return true;
}
if (
isset($item['properties']['url'][0])
&& $item['properties']['url'][0] == $url
) {
// h-card's u-url matches page URL; keep it in the result array
return true;
}
// h-card u-url does *not* match page URL (or it has no u-url); remove it from result array
return false;
});I haven't written a unit test for this yet, otherwise I would make it a PR. It did work in my local testing with the specific example link above.
I might be able to make a PR in the near future, or if someone else wants to take it on, feel free!
Metadata
Metadata
Assignees
Labels
No labels