mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 17:37:51 +01:00
Refactor code :3
This commit is contained in:
parent
42927355aa
commit
18bb13b18e
1 changed files with 19 additions and 24 deletions
|
@ -61,36 +61,31 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
j,
|
j,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get("/:v*?", async function (req, res) {
|
||||||
|
const uaos = req.useragent.os;
|
||||||
|
const browser = req.useragent.browser;
|
||||||
|
const isOldWindows =
|
||||||
|
(uaos === "Windows 7" || uaos === "Windows 8") && browser === "Firefox";
|
||||||
|
|
||||||
app.get("/:v*?", async function (req, res) {
|
const rendermainpage = () => {
|
||||||
var uaos = req.useragent.os;
|
if (req.useragent.isMobile) {
|
||||||
var IsOldWindows;
|
return res.redirect("/discover");
|
||||||
|
|
||||||
if (uaos == "Windows 7" && req.useragent.browser == "Firefox") {
|
|
||||||
IsOldWindows = true;
|
|
||||||
} else if (uaos == "Windows 8" && req.useragent.browser == "Firefox") {
|
|
||||||
IsOldWindows = true;
|
|
||||||
} else {
|
|
||||||
IsOldWindows = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const rendermainpage = () => {
|
|
||||||
if (req.useragent.isMobile) {
|
|
||||||
return res.redirect("/discover");
|
|
||||||
}
|
|
||||||
|
|
||||||
return renderTemplate(res, req, "landing.ejs", {
|
return renderTemplate(res, req, "landing.ejs", {
|
||||||
IsOldWindows
|
isOldWindows,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (req.params.v && /[a-zA-Z0-9]+/.test(req.param.v)) {
|
if (req.params.v && /[a-zA-Z0-9]+/.test(req.params.v)) {
|
||||||
const isvld = await core.isvalidvideo(req.params.v);
|
const isvld = await core.isvalidvideo(req.params.v);
|
||||||
if (isvld) {
|
if (isvld) {
|
||||||
return res.redirect(`/watch?v=${req.params.v}`);
|
return res.redirect(`/watch?v=${req.params.v}`);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rendermainpage();
|
||||||
|
});
|
||||||
|
|
||||||
return rendermainpage();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue