fix: incorrect parsing for id in API route /video/:id/snapshots
This commit is contained in:
parent
aa75fdd63e
commit
cf33c4922d
@ -43,10 +43,13 @@ export const getSnapshotsHanlder = createHandlers(async (c: ContextType) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const idParam = await idSchema.validate(c.req.param("id"));
|
const idParam = await idSchema.validate(c.req.param("id"));
|
||||||
let videoId: number | string = idParam as string | number;
|
let videoId: string | number = idParam as string;
|
||||||
if (typeof videoId === "string" && videoId.startsWith("av")) {
|
if (videoId.startsWith("av")) {
|
||||||
videoId = videoId.slice(2);
|
videoId = parseInt(videoId.slice(2));
|
||||||
}
|
}
|
||||||
|
else if (await number().validate(videoId)) {
|
||||||
|
videoId = parseInt(videoId);
|
||||||
|
}
|
||||||
const queryParams = await SnapshotQueryParamsSchema.validate(c.req.query());
|
const queryParams = await SnapshotQueryParamsSchema.validate(c.req.query());
|
||||||
const { ps, pn, offset, reverse = false } = queryParams;
|
const { ps, pn, offset, reverse = false } = queryParams;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user