mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Fix unifi with no type passing and lint
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user