fixes #63, #67, #68, and #71, among other issues
This commit is contained in:
wukko
2023-01-14 00:34:48 +06:00
parent 1a1a4534b7
commit 3b5bf51ba7
19 changed files with 218 additions and 191 deletions

View File

@@ -62,7 +62,18 @@ export function msToTime(d) {
return r;
}
export function cleanURL(url, host) {
let forbiddenChars = ['}', '{', '(', ')', '\\', '@', '%', '>', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'"]
let forbiddenChars = ['}', '{', '(', ')', '\\', '%', '>', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'", "@"]
switch(host) {
case "youtube":
url = url.split('&')[0];
break;
case "tiktok":
url = url.replace(/@([a-zA-Z]+(\.[a-zA-Z]+)+)/, "@a")
default:
url = url.split('?')[0];
if (url.substring(url.length - 1) === "/") url = url.substring(0, url.length - 1);
break;
}
for (let i in forbiddenChars) {
url = url.replaceAll(forbiddenChars[i], '')
}
@@ -70,14 +81,6 @@ export function cleanURL(url, host) {
if (url.includes('youtube.com/shorts/')) {
url = url.split('?')[0].replace('shorts/', 'watch?v=');
}
if (host === "youtube") {
url = url.split('&')[0];
} else {
url = url.split('?')[0];
if (url.substring(url.length - 1) === "/") {
url = url.substring(0, url.length - 1);
}
}
return url.slice(0, 128)
}
export function languageCode(req) {