Socket
Socket
Sign inDemoInstall

open-graph-scraper

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

open-graph-scraper - npm Package Compare versions

Comparing version 3.1.5 to 3.2.0

3

CHANGELOG.md

@@ -0,1 +1,4 @@

### 3.2.0
- website that don't have Open Graph images will now return an array of all of the images on the site
### 3.1.5

@@ -2,0 +5,0 @@ - Updating lodash to fix vulnerable

13

lib/openGraphScraper.js

@@ -189,8 +189,9 @@ 'use strict';

if (!ogObject.ogImage && ogImageFallback) {
ogObject.ogImage = [];
const supportedImageExts = ['jpg', 'jpeg', 'png'];
$('img').each(function (i, elem) {
$('img').map(function (i, elem) {
if ($(elem).attr('src') && $(elem).attr('src').length > 0 && supportedImageExts.indexOf($(elem).attr('src').split('.').pop()) !== -1) {
ogObject.ogImage = {
ogObject.ogImage.push({
url: $(elem).attr('src')
};
});
return false;

@@ -201,2 +202,8 @@ }

}
// remove ogObject.ogImage is there is nothing found
if (ogObject.ogImage === []) {
delete ogObject['ogImage'];
}
return ogObject;

@@ -203,0 +210,0 @@ };

{
"name": "open-graph-scraper",
"description": "Node.js scraper module for Open Graph and Twitter Card info",
"version": "3.1.5",
"version": "3.2.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -70,3 +70,3 @@ 'use strict';

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -86,3 +86,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -102,3 +102,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -118,3 +118,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -134,3 +134,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -165,3 +165,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -182,3 +182,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -236,3 +236,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -253,3 +253,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -270,3 +270,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -287,3 +287,3 @@ });

expect(result.data.ogDescription).to.be('Wikipedia is a free online encyclopedia, created and edited by volunteers around the world and hosted by the Wikimedia Foundation.');
expect(result.data.ogImage.url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
expect(result.data.ogImage[0].url).to.be('portal/wikipedia.org/assets/img/Wikipedia-logo-v2.png');
done();

@@ -369,3 +369,9 @@ });

expect(result.data.ogDescription).to.be('From breaking news and entertainment to sports and politics, get the full story with all the live commentary.');
expect(result.data.ogImage.url).to.be('/static/images/toolbar/wayback-toolbar-logo.png');
var imageFound = false;
for (var i = 0; i < result.data.ogImage.length; i++) {
if (result.data.ogImage[i].url === '/static/images/toolbar/wayback-toolbar-logo.png') {
imageFound = true;
};
}
expect(imageFound).to.be(true);
done();

@@ -580,3 +586,3 @@ });

expect(result.requestUrl).to.be('https://www.namecheap.com/');
expect(result.data.ogTitle).to.be('\n\tDomain Names - Cheap Domain Names | Namecheap.Com\n');
expect(result.data.ogTitle).to.be('\n\tDomain Names Starting at $0.48 - Namecheap.com\n');
done();

@@ -888,2 +894,21 @@ });

});
it('Valid Call - should get array of images back', function (done) {
app({
'url': 'https://amzn.to/2Is8sCR'
}, function (error, result) {
console.log('error:', error);
console.log('result:', result);
expect(error).to.be(false);
expect(result.success).to.be(true);
expect(result.data.ogImage.length).to.be.above(10);
var imageFound = false;
for (var i = 0; i < result.data.ogImage.length; i++) {
if (result.data.ogImage[i].url === 'https://images-eu.ssl-images-amazon.com/images/G/02/kindle-apps/buttons/sendMeLinkMedium._CB339601353_.png') {
imageFound = true;
};
}
expect(imageFound).to.be(true);
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc