mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
Fix unifi with no type passing and lint
This commit is contained in:
parent
ec79f3042a
commit
67a9f4983c
3 changed files with 15 additions and 10 deletions
|
@ -12,8 +12,11 @@ export default async function handler(req, res) {
|
|||
const { service, group } = req.query;
|
||||
const serviceWidget = await getServiceWidget(group, service);
|
||||
let type = serviceWidget?.type;
|
||||
// calendar is an alias for ical
|
||||
|
||||
// exceptions
|
||||
if (type === "calendar") type = "ical";
|
||||
else if (service === "unifi_console" && group === "unifi_console") type = "unifi_console";
|
||||
|
||||
const widget = widgets[type];
|
||||
|
||||
if (!widget) {
|
||||
|
@ -49,15 +52,17 @@ export default async function handler(req, res) {
|
|||
|
||||
if (req.query.segments) {
|
||||
const segments = JSON.parse(req.query.segments);
|
||||
for (const key in segments) {
|
||||
let validSegments = true;
|
||||
Object.keys(segments).forEach((key) => {
|
||||
if (!mapping.segments.includes(key)) {
|
||||
logger.debug("Unsupported segment: %s", key);
|
||||
return res.status(403).json({ error: "Unsupported segment" });
|
||||
validSegments = false;
|
||||
} else if (segments[key].includes("/") || segments[key].includes("\\") || segments[key].includes("..")) {
|
||||
logger.debug("Unsupported segment value: %s", segments[key]);
|
||||
return res.status(403).json({ error: "Unsupported segment value" });
|
||||
validSegments = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!validSegments) return res.status(403).json({ error: "Unsupported segment" });
|
||||
req.query.endpoint = formatApiCall(endpoint, segments);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue