mirror of
https://github.com/cupcakearmy/blaze.git
synced 2024-12-23 00:36:26 +00:00
Add handling incomlete urls
This commit is contained in:
parent
cbab36e00b
commit
9a14cc9df3
9
index.ts
9
index.ts
@ -14,12 +14,19 @@ const __filename = fileURLToPath(import.meta.url);
|
|||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
app.get("/", (req, res) => {
|
app.get("/", (req, res) => {
|
||||||
const url = req.query.at as string;
|
let url = req.query.at as string;
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
res.sendFile(path.join(__dirname + "/dist/index.html"));
|
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)
|
got(url)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const dom = new JSDOM(response.body);
|
const dom = new JSDOM(response.body);
|
||||||
|
Loading…
Reference in New Issue
Block a user