Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Fix Twitter uses 'name' not 'property' attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
pdehaan committed Sep 15, 2016
1 parent 18c334a commit c78a41a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const metadataRules = {
['meta[property="og:image:secure_url"]', node => node.element.getAttribute('content')],
['meta[property="og:image:url"]', node => node.element.getAttribute('content')],
['meta[property="og:image"]', node => node.element.getAttribute('content')],
['meta[name="twitter:image"]', node => node.element.getAttribute('content')],
['meta[property="twitter:image"]', node => node.element.getAttribute('content')],
['meta[name="thumbnail"]', node => node.element.getAttribute('content')],
],
Expand All @@ -93,6 +94,7 @@ const metadataRules = {
title: {
rules: [
['meta[property="og:title"]', node => node.element.getAttribute('content')],
['meta[name="twitter:title"]', node => node.element.getAttribute('content')],
['meta[property="twitter:title"]', node => node.element.getAttribute('content')],
['meta[name="hdl"]', node => node.element.getAttribute('content')],
['title', node => node.element.text],
Expand Down
2 changes: 2 additions & 0 deletions tests/metadataRules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('Title Rule Tests', function() {

const ruleTests = [
['og:title', `<meta property="og:title" content="${pageTitle}" />`],
['twitter:title', `<meta name="twitter:title" content="${pageTitle}" />`],
['twitter:title', `<meta property="twitter:title" content="${pageTitle}" />`],
['hdl', `<meta name="hdl" content="${pageTitle}" />`],
['title', `<title>${pageTitle}</title>`],
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('Image Rule Tests', function() {
['og:image', `<meta property="og:image" content="${pageImage}" />`],
['og:image:url', `<meta property="og:image:url" content="${pageImage}" /> `],
['og:image:secure_url', `<meta property="og:image:secure_url" content="${pageImage}" /> `],
['twitter:image', `<meta name="twitter:image" content="${pageImage}" />`],
['twitter:image', `<meta property="twitter:image" content="${pageImage}" />`],
['thumbnail', `<meta name="thumbnail" content="${pageImage}" />`],
['relative image', `<meta name="thumbnail" content="${relativeImage}" />`],
Expand Down

0 comments on commit c78a41a

Please sign in to comment.