Add handling incomlete urls

This commit is contained in:
Danny Spina 2023-06-19 01:22:20 +02:00
parent cbab36e00b
commit 9a14cc9df3

View File

@ -14,12 +14,19 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
app.get("/", (req, res) => {
const url = req.query.at as string;
let url = req.query.at as string;
if (!url) {
res.sendFile(path.join(__dirname + "/dist/index.html"));
}
var re = new RegExp("^(http|https)://", "i");
var match = re.test(url);
if (!match) {
url = `https://${url}`
}
got(url)
.then((response) => {
const dom = new JSDOM(response.body);