summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-11-17 23:25:29 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-11-17 23:25:29 +0100
commit953ddd82e48dd206cef5ac94456549aed13b3ad5 (patch)
tree8f003106ee2e7f422e5a22d2ee04d0db302e66c0 /includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js
parent62a9199846b0c07c03218703b33e8385764f42d9 (diff)
downloadpluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.gz
pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.tar.bz2
pluralconnect-953ddd82e48dd206cef5ac94456549aed13b3ad5.zip
Updated 30 files and deleted 2976 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js')
-rw-r--r--includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js43
1 files changed, 0 insertions, 43 deletions
diff --git a/includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js b/includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js
deleted file mode 100644
index 5d8ee9e..0000000
--- a/includes/external/addressbook/node_modules/open-graph-scraper/dist/lib/request.js
+++ /dev/null
@@ -1,43 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const chardet_1 = require("chardet");
-const iconv_lite_1 = require("iconv-lite");
-const utils_1 = require("./utils");
-/**
- * performs the got request and formats the body for ogs
- *
- * @param {object} gotOptions - options for got
- * @param {object} ogsOptions - options for ogs
- * @return {object} formatted request body and response
- *
- */
-async function requestAndResultsFormatter(gotOptions, ogsOptions) {
- const got = await (0, utils_1.gotClient)(ogsOptions.downloadLimit);
- return got(gotOptions)
- .then((response) => {
- if (response && response.headers && response.headers['content-type'] && !response.headers['content-type'].includes('text/')) {
- throw new Error('Page must return a header content-type with text/');
- }
- if (response && response.statusCode && (response.statusCode.toString().substring(0, 1) === '4' || response.statusCode.toString().substring(0, 1) === '5')) {
- throw new Error('Server has returned a 400/500 error code');
- }
- if (response.body === undefined || response.body === '') {
- throw new Error('Page not found');
- }
- const char = chardet_1.default.detect(response.rawBody);
- let decodedBody = response.rawBody.toString();
- if (char && typeof response.rawBody === 'object') {
- decodedBody = (0, iconv_lite_1.decode)(response.rawBody, char);
- }
- if (!decodedBody) {
- throw new Error('Page not found');
- }
- return { decodedBody, response };
- })
- .catch((error) => {
- if (error instanceof Error)
- throw error;
- throw new Error(error);
- });
-}
-exports.default = requestAndResultsFormatter;