@@ -1,8 +1,5 @@
|
||||
import { createHmac, randomUUID } from "crypto";
|
||||
import { createHmac } from "crypto";
|
||||
|
||||
export function encrypt(str, salt) {
|
||||
export function sha256(str, salt) {
|
||||
return createHmac("sha256", salt).update(str).digest("hex");
|
||||
}
|
||||
export function UUID() {
|
||||
return randomUUID();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user