mozilla / page-metadata-parser

DEPRECATED - A Javascript library for parsing metadata on a web page.
https://www.npmjs.com/package/page-metadata-parser
Mozilla Public License 2.0
270 stars 42 forks source link

Prefer canonical URLs to open-graph URLs. #100

Closed jhugman closed 6 years ago

jhugman commented 6 years ago

The og:url definition is given as:

The canonical URL of your object that will be used as its permanent ID in the graph

Since the Facebook graph is necessarily a subset of the open web, there are instances such that the page points to the closest graph node which is the wrong web page.

Currently, github provides an example of this e.g. from the page https://github.com/artsy/eidolon/tree/master/Kiosk :

<link rel="canonical" href="https://github.com/artsy/eidolon/tree/master/Kiosk" data-pjax-transient="">
<meta content="https://github.com/artsy/eidolon" property="og:url">

This PR flips the order of the rules so that the canonical link is taken before the og:url.

Original bug report: Firefox for iOS, Bug 1439349.