Socket
Socket
Sign inDemoInstall

fetch-opengraph

Package Overview
Dependencies
3
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.25 to 1.0.26

1

index.d.ts

@@ -16,2 +16,3 @@ export declare const metaTags: {

};
export declare const queryParams: (str: string) => {};
export declare const fetch: (url: string, headers?: any) => Promise<any>;

@@ -18,0 +19,0 @@ declare const _default: {

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.fetch = exports.metaTags = void 0;
exports.fetch = exports.queryParams = exports.metaTags = void 0;
const axios_1 = require("axios");

@@ -31,2 +31,21 @@ const html_entities_1 = require("html-entities");

};
const queryParams = (str) => {
const url = str.replace(/^([^#]*).*/, "$1").replace(/^[^?]*\??(.*)/, "$1");
let result = {};
const regex = /([^=]+)=([^&]+)&?/g;
let match;
do {
match = regex.exec(url);
if (match) {
// This is to prevent an possible endless loop,
// avoid "If path not taken" from code coverage since you're unable to reproduce this and it's required to prevent endless loops
/* istanbul ignore next */
if (match.index === regex.lastIndex)
regex.lastIndex++;
result = Object.assign(Object.assign({}, result), { [match[1]]: match[2] });
}
} while (match);
return result;
};
exports.queryParams = queryParams;
const fetch = (url, headers) => __awaiter(void 0, void 0, void 0, function* () {

@@ -36,3 +55,4 @@ const { title, description, ogUrl, ogType, ogTitle, ogDescription, ogImage, twitterCard, twitterDomain, twitterUrl, twitterTitle, twitterDescription, twitterImage } = exports.metaTags;

try {
const response = yield axios_1.default.get(url, {
const response = yield axios_1.default.get(url.replace(/^([^?#]*).*/, "$1"), {
params: exports.queryParams(url),
headers: Object.assign({ 'User-Agent': 'OpenGraph', 'Cache-Control': 'no-cache', Accept: '*/*', Connection: 'keep-alive' }, headers)

@@ -39,0 +59,0 @@ });

2

package.json
{
"name": "fetch-opengraph",
"version": "1.0.25",
"version": "1.0.26",
"description": "Fetch opengraph information from an url",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc