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 2.3.5 to 2.3.6

30

app.js

@@ -185,2 +185,7 @@ var request = require('request'),

multiple: true,
property: 'twitter:image:src',
fieldName: 'twitterImageSrc'
},
{
multiple: true,
property: 'twitter:image:alt',

@@ -479,2 +484,8 @@ fieldName: 'twitterImageAlt'

and sort for priority */
if (ogObject.ogImage || ogObject.ogImageWidth || ogObject.twitterImageHeight || ogObject.ogImageType) {
ogObject.ogImage = ogObject.ogImage ? ogObject.ogImage : [null];
ogObject.ogImageWidth = ogObject.ogImageWidth ? ogObject.ogImageWidth : [null];
ogObject.ogImageHeight = ogObject.ogImageHeight ? ogObject.ogImageHeight : [null];
ogObject.ogImageType = ogObject.ogImageType ? ogObject.ogImageType : [null];
}
var ogImages = _.zip(ogObject.ogImage,

@@ -488,2 +499,8 @@ ogObject.ogImageWidth,

and sort for priority */
if (ogObject.ogVideo || ogObject.ogVideoWidth || ogObject.ogVideoHeight || ogObject.ogVideoType) {
ogObject.ogVideo = ogObject.ogVideo ? ogObject.ogVideo : [null];
ogObject.ogVideoWidth = ogObject.ogVideoWidth ? ogObject.ogVideoWidth : [null];
ogObject.ogVideoHeight = ogObject.ogVideoHeight ? ogObject.ogVideoHeight : [null];
ogObject.ogVideoType = ogObject.ogVideoType ? ogObject.ogVideoType : [null];
}
var ogVideos = _.zip(ogObject.ogVideo,

@@ -497,2 +514,9 @@ ogObject.ogVideoWidth,

and sort for priority */
if (ogObject.twitterImageSrc || ogObject.twitterImage || ogObject.twitterImageWidth || ogObject.twitterImageHeight || ogObject.twitterImageAlt) {
ogObject.twitterImage = ogObject.twitterImage ? ogObject.twitterImage : ogObject.twitterImageSrc;
ogObject.twitterImage = ogObject.twitterImage ? ogObject.twitterImage : [null];
ogObject.twitterImageWidth = ogObject.twitterImageWidth ? ogObject.twitterImageWidth : [null];
ogObject.twitterImageHeight = ogObject.twitterImageHeight ? ogObject.twitterImageHeight : [null];
ogObject.twitterImageAlt = ogObject.twitterImageAlt ? ogObject.twitterImageAlt : [null];
}
var twitterImages = _.zip(ogObject.twitterImage,

@@ -506,2 +530,8 @@ ogObject.twitterImageWidth,

and sort for priority */
if (ogObject.twitterPlayer || ogObject.twitterPlayerWidth || ogObject.twitterPlayerHeight || ogObject.twitterPlayerStream) {
ogObject.twitterPlayer = ogObject.twitterPlayer ? ogObject.twitterPlayer : [null];
ogObject.twitterPlayerWidth = ogObject.twitterPlayerWidth ? ogObject.twitterPlayerWidth : [null];
ogObject.twitterPlayerHeight = ogObject.twitterPlayerHeight ? ogObject.twitterPlayerHeight : [null];
ogObject.twitterPlayerStream = ogObject.twitterPlayerStream ? ogObject.twitterPlayerStream : [null];
}
var twitterPlayers = _.zip(ogObject.twitterPlayer,

@@ -508,0 +538,0 @@ ogObject.twitterPlayerWidth,

2

package.json
{
"name": "open-graph-scraper",
"description": "Node.js scraper service for Open Graph info",
"version": "2.3.5",
"version": "2.3.6",
"license": "MIT",

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

@@ -111,2 +111,10 @@ var app = require('../app'),

// test OG and twitter tags
var optionsGithub = {
'url': 'https://github.com'
},
optionsAtom = {
'url': 'https://atom.io'
};
// test charset utf-8

@@ -353,3 +361,3 @@ var optionCharset1 = {

});
it('Valid Call - Test Twitter Tags - Should Return correct Open Graph Info + Some Twitter Info', function (done) {
it('Valid Call - Test Twitter Tags - Should Return correct Open Graph Info + Some Twitter Info - Twitter Site', function (done) {
app(optionTwitter, function (err, result) {

@@ -361,2 +369,3 @@ expect(err).to.be(false);

expect(result.data.twitterDescription).to.be('The Twitter platform connects your website or application with the worldwide conversation happening on Twitter.');
expect(result.data.twitterImage.url).to.be('https://ton.twimg.com/dtc/63872735-d8f2-4570-a7d3-b5876a62cb00/_static/imgs/twitterdev_gear.png');
expect(result.data.ogSiteName).to.be('Twitter Developers');

@@ -366,9 +375,57 @@ expect(result.data.ogTitle).to.be('Twitter Developers');

expect(result.data.ogType).to.be('website');
expect(result.data.ogImage.url).to.be('https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png');
expect(result.data.twitterImage.url).to.be('https://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png');
expect(result.data.twitterImage.width).to.be('500');
expect(result.data.twitterImage.height).to.be('500');
expect(result.data.ogImage.url).to.be('https://ton.twimg.com/dtc/63872735-d8f2-4570-a7d3-b5876a62cb00/_static/imgs/twitterdev_gear.png');
done();
});
});
it('Valid Call - Test Twitter Tags - Should Return correct Open Graph Info + Some Twitter Info - Github Site', function (done) {
app(optionsGithub, function (err, result) {
expect(err).to.be(false);
expect(result.success).to.be(true);
expect(result.data.ogUrl).to.be('https://github.com');
expect(result.data.ogSiteName).to.be('GitHub');
expect(result.data.ogTitle).to.be('Build software better, together');
expect(result.data.ogDescription).to.be('GitHub is where people build software. More than 18 million people use GitHub to discover, fork, and contribute to over 47 million projects.');
expect(result.data.ogImage.url).to.be('https://assets-cdn.github.com/images/modules/open_graph/github-logo.png');
expect(result.data.ogImage.width).to.be('1200');
expect(result.data.ogImage.height).to.be('1200');
expect(result.data.ogImage.type).to.be('image/png');
expect(result.data.twitterSite).to.be('github');
expect(result.data.twitterSiteId).to.be('13334762');
expect(result.data.twitterCreator).to.be('github');
expect(result.data.twitterCreatorId).to.be('13334762');
expect(result.data.twitterCard).to.be('summary_large_image');
expect(result.data.twitterTitle).to.be('GitHub');
expect(result.data.twitterDescription).to.be('GitHub is where people build software. More than 18 million people use GitHub to discover, fork, and contribute to over 47 million projects.');
expect(result.data.twitterImage.url).to.be('https://assets-cdn.github.com/images/modules/open_graph/github-logo.png');
expect(result.data.twitterImage.width).to.be('1200');
expect(result.data.twitterImage.height).to.be('1200');
expect(result.data.twitterImage.alt).to.be(null);
done();
});
});
it('Valid Call - Test Twitter Tags - Should Return correct Open Graph Info + Some Twitter Info - Atom Site', function (done) {
app(optionsAtom, function (err, result) {
expect(err).to.be(false);
expect(result.success).to.be(true);
expect(result.data.ogUrl).to.be('https://atom.io/');
expect(result.data.ogSiteName).to.be('Atom');
expect(result.data.ogTitle).to.be('A hackable text editor for the 21st Century');
expect(result.data.ogDescription).to.be('At GitHub, we’re building the text editor we’ve always wanted: hackable to the core, but approachable on the first day without ever touching a config file. We can’t wait to see what you build with it.');
expect(result.data.ogType).to.be('website');
expect(result.data.twitterCard).to.be('summary_large_image');
expect(result.data.twitterSite).to.be('@AtomEditor');
expect(result.data.twitterCreator).to.be('@github');
expect(result.data.twitterTitle).to.be('Atom');
expect(result.data.twitterDescription).to.be('A hackable text editor for the 21st Century');
expect(result.data.ogImage.url).to.be('http://og.github.com/atom-mark/atom-mark@1200x630.png');
expect(result.data.ogImage.width).to.be('1200');
expect(result.data.ogImage.height).to.be('630');
expect(result.data.ogImage.type).to.be(null);
expect(result.data.twitterImage.url).to.be('http://og.github.com/atom-logo/atom-logo@1200x630.png');
expect(result.data.twitterImage.width).to.be('1200');
expect(result.data.twitterImage.height).to.be('630');
expect(result.data.twitterImage.alt).to.be(null);
done();
});
});
it('Valid Call - Utf-8 charset - Should Return correct Open Graph Info + charset info', function (done) {

@@ -375,0 +432,0 @@ app(optionCharset1, function (err, result) {

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