Skip to content

Commit 1dd1a05

Browse files
committed
simpler oembed.js
1 parent 5149524 commit 1dd1a05

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/plugins/system/oembed/oembed.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,17 @@ function _getOembedIframe(oembed) {
4444
html = entities.decodeHTML(html);
4545
}
4646

47-
var $container = cheerio.load('<div></div>')('div');
47+
var $iframe = null;
4848
try {
49-
$container.html(html);
49+
var $iframe = cheerio.load(html)('iframe');
5050
} catch (ex) {}
51-
var $iframe = $container.find('iframe');
5251

53-
if ($iframe.length === 2 && /<iframe>$/i.test(html)) {
52+
if ($iframe && $iframe.length === 2 && /<iframe>$/i.test(html)) {
5453
// Forgive mis-closed iFrame tag
5554
$iframe = $iframe.first();
5655
}
5756

58-
if ($iframe.length === 1) {
57+
if ($iframe && $iframe.length === 1) {
5958
_iframe = fixOembedIframeAttributes($iframe[0].attribs);
6059
_iframe.placeholder = oembed.thumbnail_url;
6160
}

0 commit comments

Comments
 (0)