Linkvertise try number 2

This commit is contained in:
2025-03-12 14:16:08 -04:00
parent 5082135d62
commit b1c3d9ef84
4 changed files with 20 additions and 13 deletions

View File

@@ -38,4 +38,21 @@ export function encodeId(documentId: string): string {
export function decodeId(encodedId: string): string {
const salt = "salty_aff"
return Buffer.from(encodedId, 'base64').toString().replace(salt, '')
}
export function btoa(str: string): string {
let buffer: Buffer;
if (Buffer.isBuffer(str)) {
buffer = str;
} else {
buffer = Buffer.from(str, "binary");
}
return buffer.toString("base64");
}
export function linkvertise(userid: number, link: string): string {
let base_url = `https://link-to.net/${userid}/${Math.floor(Math.random() * 1000)}/dynamic`;
let href = `${base_url}?r=${btoa(encodeURI(link))}`;
return href;
}