api requests work, added simple tests... TODO: URL Object needs to be cloned for memory safety

This commit is contained in:
fzzin
2025-04-10 11:37:18 +02:00
parent aa834bda66
commit ab6ec7fc3d
3 changed files with 27 additions and 55 deletions

View File

@@ -1,42 +0,0 @@
import {DiscordEmbedImage} from "npm:discordeno@18.0.1";
import {}
export function drop(): DiscordEmbedImage {
const tmp = await
return {url: }
}
export function requestWorker(request: string): DiscordEmbedImage[] {
}
function isKey<T>(keys: string[], key: string): key is T {
return keys.includes(key as any);
}
export function requestParser<T>(requestString: string) {
const res = requestString.match(/\[([\s*w+:\s*[\d+|\w+,]+)\]/g);
const map = new Map<T, string>();
if (res !== null) {
res[0]
.split(",")
.forEach((param) => {
const match = param.match(/\s*(\w+)\s*:\s*([\w+,+]+)/);
console.debug({ match });
if (match !== null) {
if (match[1] === undefined || match[2] === undefined) {
throw Error("Unreachable");
}
if (!isKey(match[1])) throw Error(`Key: ${match[1]} is not a Key!`);
map.set(match[1], match[2]);
} else {
throw Error(`match returned null in param = ${Deno.inspect(param)}`);
}
});
} else {
throw Error("Request String had some major issues chief");
}
console.debug();
return map;
}