fix video search

This commit is contained in:
ashley 2024-05-05 12:57:16 +00:00
parent ae935825f4
commit ab96d0fa34

View file

@ -110,9 +110,11 @@ module.exports = function (app, config, renderTemplate) {
if (query) { if (query) {
let redirectTo = null; let redirectTo = null;
let splitParam = ":";
if (query.includes("youtube.com/watch?v=")) { if (query.includes("youtube.com/watch?v=")) {
redirectTo = "/watch?v="; redirectTo = "/watch";
splitParam = "?v=";
} else if (query.includes("channel:")) { } else if (query.includes("channel:")) {
redirectTo = "/channel?id="; redirectTo = "/channel?id=";
} else if (query.includes("video:")) { } else if (query.includes("video:")) {
@ -121,8 +123,8 @@ module.exports = function (app, config, renderTemplate) {
if (redirectTo) { if (redirectTo) {
try { try {
const id = query.split(":")[1]; const id = query.split(splitParam)[1];
res.redirect(`${redirectTo}${id}`); res.redirect(`${redirectTo}${splitParam}${id}`);
} catch { } catch {
return; return;
} }