fix: remove repository link display on missing param errors (#4560)

* fix: remove repository link display on missing param errors

* fix tests

---------

Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
This commit is contained in:
Ophelia Goldstein
2025-10-25 18:35:12 +02:00
committed by martin-mfg
co-authored by Alexandr
parent 58570c42f7
commit 2e45763952
6 changed files with 22 additions and 4 deletions
+5 -1
View File
@@ -12,7 +12,10 @@ import {
setErrorCacheHeaders,
} from "../src/common/cache.js";
import { guardAccess } from "../src/common/access.js";
import { retrieveSecondaryMessage } from "../src/common/error.js";
import {
MissingParamError,
retrieveSecondaryMessage,
} from "../src/common/error.js";
// @ts-ignore
export default async (req, res) => {
@@ -104,6 +107,7 @@ export default async (req, res) => {
bg_color,
border_color,
theme,
show_repo_link: !(err instanceof MissingParamError),
},
}),
);
+5 -1
View File
@@ -8,7 +8,10 @@ import {
setCacheHeaders,
setErrorCacheHeaders,
} from "../src/common/cache.js";
import { retrieveSecondaryMessage } from "../src/common/error.js";
import {
MissingParamError,
retrieveSecondaryMessage,
} from "../src/common/error.js";
import { parseArray, parseBoolean, renderError } from "../src/common/utils.js";
import { fetchRepo } from "../src/fetchers/repo.js";
import { isLocaleAvailable } from "../src/translations.js";
@@ -151,6 +154,7 @@ export default async (req, res) => {
bg_color,
border_color,
theme,
show_repo_link: !(err instanceof MissingParamError),
},
}),
);
+5 -1
View File
@@ -8,7 +8,10 @@ import {
setCacheHeaders,
setErrorCacheHeaders,
} from "../src/common/cache.js";
import { retrieveSecondaryMessage } from "../src/common/error.js";
import {
MissingParamError,
retrieveSecondaryMessage,
} from "../src/common/error.js";
import { parseArray, parseBoolean, renderError } from "../src/common/utils.js";
import { fetchTopLanguages } from "../src/fetchers/top-languages.js";
import { isLocaleAvailable } from "../src/translations.js";
@@ -167,6 +170,7 @@ export default async (req, res) => {
bg_color,
border_color,
theme,
show_repo_link: !(err instanceof MissingParamError),
},
}),
);
+5 -1
View File
@@ -12,7 +12,10 @@ import {
setErrorCacheHeaders,
} from "../src/common/cache.js";
import { guardAccess } from "../src/common/access.js";
import { retrieveSecondaryMessage } from "../src/common/error.js";
import {
MissingParamError,
retrieveSecondaryMessage,
} from "../src/common/error.js";
// @ts-ignore
export default async (req, res) => {
@@ -123,6 +126,7 @@ export default async (req, res) => {
bg_color,
border_color,
theme,
show_repo_link: !(err instanceof MissingParamError),
},
}),
);
+1
View File
@@ -129,6 +129,7 @@ describe("Test /api/gist", () => {
renderError({
message: 'Missing params "id" make sure you pass the parameters in URL',
secondaryMessage: "/api/gist?id=GIST_ID",
renderOptions: { show_repo_link: false },
}),
);
});
+1
View File
@@ -212,6 +212,7 @@ describe("Test /api/pin", () => {
message:
'Missing params "username", "repo" make sure you pass the parameters in URL',
secondaryMessage: "/api/pin?username=USERNAME&amp;repo=REPO_NAME",
renderOptions: { show_repo_link: false },
}),
);
});