Support repeated stopIds and update WienerLinien API URL

This commit is contained in:
2026-05-10 18:06:41 +02:00
parent b2608a4a60
commit de9c16430b
6 changed files with 23 additions and 10 deletions
+3 -4
View File
@@ -6,13 +6,12 @@ const client = new WienerLinienClient();
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const stopIdsParam = searchParams.get("stopIds");
if (!stopIdsParam || stopIdsParam.trim() === "") {
const stopIdsList = searchParams.getAll("stopIds");
if (stopIdsList.length === 0 || stopIdsList.every((v) => v.trim() === "")) {
return NextResponse.json({ error: "Missing 'stopIds' query parameter" }, { status: 400 });
}
const rawIds = stopIdsParam.split(",");
const rawIds = stopIdsList.flatMap((param) => param.split(","));
const validStopIds = rawIds
.map((id) => id.trim())
.filter((id) => id.length > 0)