mirror of
https://github.com/theoleuthardt/werkzeugkiste.git
synced 2026-06-13 09:37:53 +00:00
no comments needed
This commit is contained in:
parent
544ebaa7cf
commit
fd4103240a
1 changed files with 1 additions and 5 deletions
|
|
@ -18,12 +18,10 @@ export async function regexTest(app: FastifyInstance) {
|
||||||
return reply.status(400).send({ error: "No Regex declared!" });
|
return reply.status(400).send({ error: "No Regex declared!" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Überprüfe, ob die Felder regex und test vorhanden sind
|
|
||||||
if (!data.regex || !data.test) {
|
if (!data.regex || !data.test) {
|
||||||
return reply.status(400).send({ error: "Regex or test string missing!" });
|
return reply.status(400).send({ error: "Regex or test string missing!" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Versuche, den regulären Ausdruck zu erstellen
|
|
||||||
let regexPattern;
|
let regexPattern;
|
||||||
try {
|
try {
|
||||||
regexPattern = new RegExp(data.regex);
|
regexPattern = new RegExp(data.regex);
|
||||||
|
|
@ -31,10 +29,8 @@ export async function regexTest(app: FastifyInstance) {
|
||||||
return reply.status(400).send({ error: "Invalid regular expression!" });
|
return reply.status(400).send({ error: "Invalid regular expression!" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teste den Eingabestring gegen das Regex
|
|
||||||
const result = regexPattern.test(data.test);
|
const result = regexPattern.test(data.test);
|
||||||
|
|
||||||
// Erstelle die Antwort basierend auf dem Testergebnis
|
|
||||||
let output = "";
|
let output = "";
|
||||||
if (result) {
|
if (result) {
|
||||||
output = `The input matches the regular expression!`;
|
output = `The input matches the regular expression!`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue