Skip to content

Commit fe0e493

Browse files
iparamonaunleush
authored andcommitted
[Domains] Review oEmbed Meta deprecation for Facebook and Instagram
1 parent 271bb8c commit fe0e493

File tree

2 files changed

+8
-57
lines changed

2 files changed

+8
-57
lines changed

plugins/domains/facebook.com/facebook.meta.js

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,21 @@ import * as entities from 'entities';
22

33
export default {
44

5-
/**
6-
* HEADS-UP: New endpoints as of Oct 24, 2020:
7-
* https://developers.facebook.com/docs/plugins/oembed/
8-
* Please configure your `access_token` in your local config file
9-
* as desribed on https://github.com/itteco/iframely/issues/284.
10-
*/
11-
125
re: [
136
'facebook.post',
147
'facebook.video'
158
],
169

1710
mixins: [
1811
"domain-icon",
19-
"oembed-author",
20-
"oembed-canonical",
2112
"oembed-site"
2213
],
2314

24-
getMeta: function(oembed) {
25-
26-
if (oembed.html) {
27-
28-
var description = oembed.html.match(/<p>([^<>]+)<\/p>/i);
29-
description = description ? description[1]: '';
30-
31-
var author = oembed.html.match(/Posted by <a(?:[^<>]+)>([^<>]+)<\/a>/);
32-
author = author ? author[1]: oembed.author_name;
33-
34-
var title = oembed.html.match(/>([^<>]+)<\/a><p>/i);
35-
title = title ? title[1] : author;
36-
37-
return {
38-
title: title ? entities.decodeHTML(title) : oembed.title,
39-
description: description ? entities.decodeHTML(description) : oembed.description,
40-
author: author
41-
};
15+
getMeta: function(__allowFBThumbnail, meta) {
16+
return {
17+
title: meta.twitter?.title || meta.og?.title,
18+
description: meta.twitter?.description || meta.og?.description,
19+
canonical: meta.og?.url
4220
}
4321
},
4422

plugins/domains/instagram.com/instagram.com.js

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,10 @@ export default {
2929
provides: ['ipOG', '__allowInstagramMeta'],
3030

3131
getMeta: function (oembed, urlMatch, ipOG) {
32-
33-
var title = ipOG.title;
34-
var description = ipOG.description || oembed.title;
35-
36-
if (!description || !title || /login/i.test(title)) {
37-
var $container = cheerio('<div>');
38-
try {
39-
$container.html(decodeHTML5(oembed.html));
40-
} catch (ex) {}
41-
42-
if (!title || /login/i.test(title)) {
43-
var $a = $container.find(`p a[href*="${oembed.author_name}"], p a[href*="${urlMatch[1]}"]`);
44-
45-
if ($a.length == 1) {
46-
title = $a.text();
47-
title += /@/.test(title) ? '' : (oembed.author_name ? ` (@${oembed.author_name})` : '');
48-
} else if (oembed.author_name) {
49-
title = `Instagram (@${oembed.author_name})`;
50-
}
51-
}
52-
53-
if (!description) {
54-
var $a = $container.find(`p a[href*="${urlMatch[1]}"]`);
55-
description = $a.text();
56-
}
57-
}
58-
5932
return {
60-
title: title,
61-
description: description,
62-
canonical: `https://www.instagram.com/p/${urlMatch[1]}`
33+
title: ipOG.title,
34+
description: ipOG.description,
35+
canonical: ipOG.url || `https://www.instagram.com/p/${urlMatch[1]}`
6336
}
6437
},
6538

0 commit comments

Comments
 (0)