mirror of
https://github.com/theoleuthardt/werkzeugkiste.git
synced 2026-06-13 09:37:53 +00:00
Merge remote-tracking branch 'origin/feat/regex-tester' into feat/regex-tester
This commit is contained in:
commit
1014e9c07b
1 changed files with 1 additions and 5 deletions
|
|
@ -18,14 +18,12 @@ 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
|
return reply
|
||||||
.status(400)
|
.status(400)
|
||||||
.send({ error: "Regex or test string missing!" });
|
.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);
|
||||||
|
|
@ -35,10 +33,8 @@ export async function regexTest(app: FastifyInstance) {
|
||||||
.send({ error: "Invalid regular expression!" });
|
.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