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

link-preview-js

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

link-preview-js - npm Package Compare versions

Comparing version 3.0.0 to 3.0.2

build/__tests__/index.spec.d.ts

37

build/index.js

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

return __awaiter(this, void 0, void 0, function () {
var detectedUrl, resolvedUrl, timeout, controller, timeoutCounter, fetchOptions, fetchUrl, response, headers, normalizedResponse;
var detectedUrl, resolvedUrl, timeout, controller, timeoutCounter, fetchOptions, fetchUrl, response, forwardedUrl, resolvedUrl, headers, normalizedResponse;
var _d;

@@ -363,18 +363,7 @@ return __generator(this, function (_e) {

: detectedUrl;
return [4 /*yield*/, (0, cross_fetch_1.fetch)(fetchUrl, fetchOptions)
.then(function (res) {
if ((res.status === 301 || res.status === 302) &&
fetchOptions.redirect === "manual" &&
(options === null || options === void 0 ? void 0 : options.handleRedirects)) {
if (!options.handleRedirects(fetchUrl, (res.headers.get("location") || ""))) {
throw new Error("link-preview-js could not handle redirect");
}
return (0, cross_fetch_1.fetch)(res.headers.get("location") || "", fetchOptions);
}
return res;
})
.catch(function (e) {
return [4 /*yield*/, (0, cross_fetch_1.fetch)(fetchUrl, fetchOptions).catch(function (e) {
if (e.name === "AbortError") {
throw new Error("Request timeout");
}
clearTimeout(timeoutCounter);
throw e;

@@ -384,2 +373,20 @@ })];

response = _e.sent();
if (!((response.status > 300 || response.status < 309) &&
fetchOptions.redirect === "manual" &&
(options === null || options === void 0 ? void 0 : options.handleRedirects))) return [3 /*break*/, 7];
forwardedUrl = response.headers.get("location") || "";
if (!options.handleRedirects(fetchUrl, forwardedUrl)) {
throw new Error("link-preview-js could not handle redirect");
}
if (!!!(options === null || options === void 0 ? void 0 : options.resolveDNSHost)) return [3 /*break*/, 5];
return [4 /*yield*/, options.resolveDNSHost(forwardedUrl)];
case 4:
resolvedUrl = _e.sent();
throwOnLoopback(resolvedUrl);
_e.label = 5;
case 5: return [4 /*yield*/, (0, cross_fetch_1.fetch)(forwardedUrl, fetchOptions)];
case 6:
response = _e.sent();
_e.label = 7;
case 7:
clearTimeout(timeoutCounter);

@@ -397,3 +404,3 @@ headers = {};

return [4 /*yield*/, response.text()];
case 4:
case 8:
normalizedResponse = (_d.data = _e.sent(),

@@ -400,0 +407,0 @@ _d);

{
"name": "link-preview-js",
"version": "3.0.0",
"version": "3.0.2",
"description": "Javascript module to extract and fetch HTTP link information from blocks of text.",

@@ -44,8 +44,8 @@ "main": "build/index.js",

"@types/cheerio": "0.22.24",
"@types/jest": "^26.0.19",
"jest": "^26.6.3",
"@types/jest": "^28.1.4",
"jest": "^28.1.2",
"prettier": "2.7.1",
"ts-jest": "^26.4.4",
"ts-jest": "^28.0.5",
"typescript": "^4.7.4"
}
}
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