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.6.0 to 4.7.0

4

CHANGELOG.md
# Change Log
## 4.7.0
- Adding `options.urlValidatorSettings`, it sets the options used by validator.js for testing the URL
- Updating Dependencies
## 4.6.0

@@ -4,0 +8,0 @@ - Fixing issue where you would get a false positive errors with pages that have `.tar` in it like `www.target.com`

2

lib/fallback.js

@@ -43,3 +43,3 @@ const { findImageTypeFromUrl, isImageTypeValid, isUrlValid } = require('./utils');

const type = findImageTypeFromUrl(source);
if (!isUrlValid(source) || !isImageTypeValid(type)) return false;
if (!isUrlValid(source, options.urlValidatorSettings) || !isImageTypeValid(type)) return false;
ogObject.ogImage.push({

@@ -46,0 +46,0 @@ url: source,

@@ -21,4 +21,21 @@ const { extractMetaTags } = require('./extract');

const validate = utils.validate(options.url, options.timeout);
if (!options.urlValidatorSettings) {
// set the default URL validator Settings
options.urlValidatorSettings = {
protocols: ['http', 'https'],
require_tld: true,
require_protocol: false,
require_host: true,
require_valid_protocol: true,
allow_underscores: false,
host_whitelist: false,
host_blacklist: false,
allow_trailing_dot: false,
allow_protocol_relative_urls: false,
disallow_auth: false,
};
}
const validate = utils.validate(options.url, options.timeout, options.urlValidatorSettings);
if (!validate.url) throw new Error('Invalid URL');

@@ -25,0 +42,0 @@

@@ -7,15 +7,3 @@ const validator = require('validator');

*/
exports.isUrlValid = (url) => typeof url === 'string' && url.length > 0 && validator.isURL(url, {
protocols: ['http', 'https'],
require_tld: true,
require_protocol: false,
require_host: true,
require_valid_protocol: true,
allow_underscores: false,
host_whitelist: false,
host_blacklist: false,
allow_trailing_dot: false,
allow_protocol_relative_urls: false,
disallow_auth: false,
});
exports.isUrlValid = (url, urlValidatorSettings) => typeof url === 'string' && url.length > 0 && validator.isURL(url, urlValidatorSettings);

@@ -38,4 +26,4 @@ /*

*/
exports.validate = (url, timeout) => ({
url: this.isUrlValid(url) ? coerceUrl(url) : null,
exports.validate = (url, timeout, urlValidatorSettings) => ({
url: this.isUrlValid(url, urlValidatorSettings) ? coerceUrl(url) : null,
timeout: isTimeoutValid(timeout) ? timeout : 2000,

@@ -42,0 +30,0 @@ });

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

@@ -27,7 +27,7 @@ "main": "index.js",

"dependencies": {
"chardet": "^1.2.1",
"chardet": "^1.3.0",
"cheerio": "^1.0.0-rc.3",
"got": "^11.6.2",
"got": "^11.8.0",
"iconv-lite": "^0.6.2",
"validator": "^13.0.0"
"validator": "^13.1.17"
},

@@ -40,15 +40,15 @@ "files": [

"chai": "^4.2.0",
"eslint": "^7.8.1",
"eslint": "^7.12.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"markdownlint-cli": "^0.23.2",
"mocha": "^8.1.3",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"markdownlint-cli": "^0.24.0",
"mocha": "^8.2.1",
"nyc": "^15.0.1",
"sinon": "^9.0.3",
"snyk": "^1.393.0"
"sinon": "^9.2.1",
"snyk": "^1.422.0"
},

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

@@ -77,2 +77,3 @@ # openGraphScraper

| peekSize | Sets the peekSize for the request | 1024 | |
| urlValidatorSettings | Sets the options used by validator.js for testing the URL | [Here](https://github.com/jshemas/openGraphScraper/blob/master/lib/openGraphScraper.js#L21-L36) | |

@@ -79,0 +80,0 @@ Note: `open-graph-scraper` uses [got](https://github.com/sindresorhus/got) for requests and most of [got's options](https://github.com/sindresorhus/got#options) should work as `open-graph-scraper` options.

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