Files
anything-llm/collector/utils/http/index.js
Timothy Carambat fd4929b4d2 Feature/drupalwiki collector (#3693)
* Implement DrupalWiki collector

* Add attachment downloading and processing functionality (#3)

* linting

* Linting
Add citation image
small refactors
add URL for citation identifier

---------

Co-authored-by: em <eugen.mayer@kontextwork.de>
Co-authored-by: rexjohannes <53578137+rexjohannes@users.noreply.github.com>
Co-authored-by: Eugen Mayer <136934+EugenMayer@users.noreply.github.com>
2025-04-21 09:17:24 -07:00

36 lines
781 B
JavaScript

process.env.NODE_ENV === "development"
? require("dotenv").config({ path: `.env.${process.env.NODE_ENV}` })
: require("dotenv").config();
function reqBody(request) {
return typeof request.body === "string"
? JSON.parse(request.body)
: request.body;
}
function queryParams(request) {
return request.query;
}
/**
* Validates if the provided baseUrl is a valid URL at all.
* - Does not validate if the URL is reachable or accessible.
* - Does not do any further validation of the URL like `validURL` in `utils/url/index.js`
* @param {string} baseUrl
* @returns {boolean}
*/
function validBaseUrl(baseUrl) {
try {
new URL(baseUrl);
return true;
} catch (e) {
return false;
}
}
module.exports = {
reqBody,
queryParams,
validBaseUrl,
};