mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-28 06:51:17 -07:00
Chore: simplify sanitizeErrorURL
This commit is contained in:
@@ -77,7 +77,7 @@ describe("widgets/dockhand/proxy", () => {
|
||||
|
||||
expect(res.statusCode).toBe(500);
|
||||
expect(res.body.error.message).toBe("HTTP Error");
|
||||
expect(res.body.error.url).toContain("token=***");
|
||||
expect(res.body.error.url).toBe("dockhand (see logs for details)");
|
||||
});
|
||||
|
||||
it("supports token auth", async () => {
|
||||
|
||||
@@ -47,7 +47,14 @@ export default async function frigateProxyHandler(req, res, map) {
|
||||
});
|
||||
|
||||
if (loginStatus !== 200) {
|
||||
logger.error("HTTP Error %d calling %s", loginStatus, sanitizeErrorURL(loginUrl));
|
||||
const errorURL = new URL(loginUrl);
|
||||
logger.error(
|
||||
"HTTP Error %d calling %s//%s%s...",
|
||||
loginStatus,
|
||||
errorURL.protocol,
|
||||
errorURL.host,
|
||||
errorURL.pathname,
|
||||
);
|
||||
return res.status(status).json({
|
||||
error: {
|
||||
message: `HTTP Error ${status} while trying to login to Frigate`,
|
||||
@@ -63,7 +70,8 @@ export default async function frigateProxyHandler(req, res, map) {
|
||||
}
|
||||
|
||||
if (status >= 400) {
|
||||
logger.error("HTTP Error %d calling %s", status, sanitizeErrorURL(url));
|
||||
const errorURL = new URL(url);
|
||||
logger.error("HTTP Error %d calling %s//%s%s...", status, errorURL.protocol, errorURL.host, errorURL.pathname);
|
||||
return res.status(status).json({
|
||||
error: {
|
||||
message: `HTTP Error ${status} from Frigate`,
|
||||
|
||||
@@ -99,7 +99,7 @@ describe("widgets/frigate/proxy", () => {
|
||||
expect.objectContaining({
|
||||
error: expect.objectContaining({
|
||||
message: "HTTP Error 401 from Frigate",
|
||||
url: "http://frigate/api/stats",
|
||||
url: "frigate (see logs for details)",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
@@ -162,7 +162,7 @@ describe("widgets/frigate/proxy", () => {
|
||||
expect.objectContaining({
|
||||
error: expect.objectContaining({
|
||||
message: "HTTP Error 401 while trying to login to Frigate",
|
||||
url: "http://frigate/api/stats",
|
||||
url: "frigate (see logs for details)",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -34,7 +34,8 @@ export default async function komodoProxyHandler(req, res) {
|
||||
let resultData = data;
|
||||
|
||||
if (status >= 400) {
|
||||
logger.error("HTTP Error %d calling %s", status, sanitizeErrorURL(url));
|
||||
const errorURL = new URL(url);
|
||||
logger.error("HTTP Error %d calling %s//%s%s...", status, errorURL.protocol, errorURL.host, errorURL.pathname);
|
||||
}
|
||||
|
||||
if (status === 200) {
|
||||
|
||||
Reference in New Issue
Block a user