fix: incorrect parsing for id in API route /video/:id/snapshots

This commit is contained in:
alikia2x (寒寒) 2025-03-31 06:09:28 +08:00
parent aa75fdd63e
commit cf33c4922d
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6

View File

@ -43,10 +43,13 @@ export const getSnapshotsHanlder = createHandlers(async (c: ContextType) => {
try {
const idParam = await idSchema.validate(c.req.param("id"));
let videoId: number | string = idParam as string | number;
if (typeof videoId === "string" && videoId.startsWith("av")) {
videoId = videoId.slice(2);
let videoId: string | number = idParam as string;
if (videoId.startsWith("av")) {
videoId = parseInt(videoId.slice(2));
}
else if (await number().validate(videoId)) {
videoId = parseInt(videoId);
}
const queryParams = await SnapshotQueryParamsSchema.validate(c.req.query());
const { ps, pn, offset, reverse = false } = queryParams;