no comments needed

This commit is contained in:
Theo Leuthardt 2025-02-20 20:24:01 +01:00 committed by GitHub
parent 544ebaa7cf
commit fd4103240a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,12 +18,10 @@ export async function regexTest(app: FastifyInstance) {
return reply.status(400).send({ error: "No Regex declared!" });
}
// Überprüfe, ob die Felder regex und test vorhanden sind
if (!data.regex || !data.test) {
return reply.status(400).send({ error: "Regex or test string missing!" });
}
// Versuche, den regulären Ausdruck zu erstellen
let regexPattern;
try {
regexPattern = new RegExp(data.regex);
@ -31,10 +29,8 @@ export async function regexTest(app: FastifyInstance) {
return reply.status(400).send({ error: "Invalid regular expression!" });
}
// Teste den Eingabestring gegen das Regex
const result = regexPattern.test(data.test);
// Erstelle die Antwort basierend auf dem Testergebnis
let output = "";
if (result) {
output = `The input matches the regular expression!`;