Skip to content

Commit

Permalink
Improve suggested blacklist tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamSwiss committed Jan 17, 2025
1 parent 5da5e76 commit 4b491f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions express/backend/src/api/weblate-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { Router } from "express";
import { env } from "../common";

const WEBLATE_API = "https://weblate.iobroker.net/api/";
const ALLOWED_PATHS = ["/projects/", "/components/", "/languages/"];
const ALLOWED_PATHS = ["projects/adapters/components/"] as const;

const router = Router();

router.get<any>("/api/weblate/*", async function (req, res) {
try {
const userPath = `/${req.params["0"]}`;
if (!ALLOWED_PATHS.some(path => userPath.startsWith(path))) {
const userPath = req.params["0"];
if (!ALLOWED_PATHS.some((path) => userPath.startsWith(path))) {
return res.status(400).send("Invalid path");
}
const url = new URL(`${WEBLATE_API}${req.params["0"]}`);
const url = new URL(`${WEBLATE_API}${userPath}`);
const q = req.query;
if (q.page) {
url.searchParams.set("page", q.page as string);
Expand Down

0 comments on commit 4b491f9

Please sign in to comment.