Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 4.5.0 to 4.5.1

4

CHANGELOG.md
# Change Log
## 4.5.1
- Fixing issue where you couldn't set the `ogImageFallback` option to false
- Fixing image type fallback so it works with arrays
## 4.5.0

@@ -4,0 +8,0 @@ - Adding support for custom meta tags you want to scrape

@@ -54,6 +54,16 @@ const { findImageTypeFromUrl, isImageTypeValid, isUrlValid } = require('./utils');

if (ogObject.ogImage.length === 0) delete ogObject.ogImage;
} else if (ogObject.ogImage && ogObject.ogImage.url && !ogObject.ogImage.type) {
} else if (ogObject.ogImage) {
// if there isn't a type, try to pull it from the URL
const type = findImageTypeFromUrl(ogObject.ogImage.url);
if (isImageTypeValid(type)) ogObject.ogImage.type = type;
if (Array.isArray(ogObject.ogImage)) {
ogObject.ogImage.map((image) => {
if (image.url && !image.type) {
const type = findImageTypeFromUrl(image.url);
if (isImageTypeValid(type)) image.type = type;
}
return false;
});
} else if (ogObject.ogImage.url && !ogObject.ogImage.type) {
const type = findImageTypeFromUrl(ogObject.ogImage.url);
if (isImageTypeValid(type)) ogObject.ogImage.type = type;
}
}

@@ -60,0 +70,0 @@

23

lib/openGraphScraper.js

@@ -131,12 +131,15 @@ const cheerio = require('cheerio');

options.timeout = validate.timeout;
options.decompress = options.decompress || true;
options.peekSize = options.peekSize || 1024;
options.followRedirect = options.followRedirect || true;
options.maxRedirects = options.maxRedirects || 10;
options.retry = options.retry || 2;
options.onlyGetOpenGraphInfo = options.onlyGetOpenGraphInfo || false;
options.ogImageFallback = options.ogImageFallback || true;
options.allMedia = options.allMedia || false;
options.headers = options.headers || {};
options.responseType = options.responseType || 'buffer';
options = {
decompress: true,
peekSize: 1024,
followRedirect: true,
maxRedirects: 10,
retry: 2,
onlyGetOpenGraphInfo: false,
ogImageFallback: true,
allMedia: false,
headers: {},
responseType: 'buffer',
...options,
};

@@ -143,0 +146,0 @@ if (options.encoding === null) {

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

@@ -39,3 +39,3 @@ "main": "index.js",

"chai": "^4.2.0",
"eslint": "^7.5.0",
"eslint": "^7.6.0",
"eslint-config-airbnb": "^18.0.1",

@@ -46,9 +46,9 @@ "eslint-plugin-import": "^2.22.0",

"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"markdownlint-cli": "^0.23.2",
"mocha": "^8.0.1",
"mocha": "^8.1.0",
"nyc": "^15.0.1",
"sinon": "^9.0.2",
"snyk": "^1.364.2"
"snyk": "^1.369.2"
},

@@ -55,0 +55,0 @@ "repository": {

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