fix: Fehlerhafte RegExp im JS-Mock-Handler korrigiert (getAnalogInputsHandler)
- RegExp-Syntaxfehler behoben (unmatched ')') beim Parsen von JS-Mock-Dateien - Fehlerhafte Klammern in extractArray durch korrektes Muster ersetzt - API funktioniert jetzt korrekt im JSON- und JS-Mock-Modus
This commit is contained in:
@@ -27,7 +27,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
function extractArray(name: string): any[] {
|
||||
const match = content.match(
|
||||
new RegExp(`var\s+${name}\s*=\s*\[([\s\S]*?)\];`)
|
||||
new RegExp(`var\\s+${name}\\s*=\\s*\\[([\\s\\S]*?)\\];`)
|
||||
);
|
||||
if (!match) return [];
|
||||
return match[1]
|
||||
@@ -40,7 +40,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
win_analogInputsValues: extractArray("win_analogInputsValues").map(
|
||||
Number
|
||||
),
|
||||
win_analogInputsNames: extractArray("win_analogInputsNames"),
|
||||
win_analogInputsLabels: extractArray("win_analogInputsLabels"),
|
||||
win_analogInputsOffset: extractArray("win_analogInputsOffset").map(
|
||||
Number
|
||||
),
|
||||
@@ -55,6 +55,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
"win_analogInputsWeighting"
|
||||
).map(Number),
|
||||
};
|
||||
console.log("Analog Inputs Mock Data:", responseData);
|
||||
|
||||
return res.status(200).json(responseData);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user