link-preview-js
Advanced tools
Comparing version 3.0.0 to 3.0.2
@@ -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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
670755
10
3338
1