1 Commits
1.81 ... 1.82

Author SHA1 Message Date
fbfd20c965 invidiousAPI: handle slashes 2025-02-22 02:04:05 -08:00
2 changed files with 3 additions and 2 deletions

View File

@@ -32,7 +32,7 @@ export const getInvidiousSearchURL = (query: string): string =>
`${INVIDIOUS_API_ENDPOINT}/search?q=${encodeURIComponent(query)}`; `${INVIDIOUS_API_ENDPOINT}/search?q=${encodeURIComponent(query)}`;
export const getInvidiousThumbnailURL = (url: string): string => export const getInvidiousThumbnailURL = (url: string): string =>
`${INVIDIOUS_BASE_URL}${url}`; `${INVIDIOUS_BASE_URL}/${url}`;
const preferredThumbnailAPIURL = (thumbnails: InvidiousVideoThumbnail[] | undefined): string => { const preferredThumbnailAPIURL = (thumbnails: InvidiousVideoThumbnail[] | undefined): string => {
if (!thumbnails || thumbnails.length === 0) { if (!thumbnails || thumbnails.length === 0) {

View File

@@ -118,7 +118,8 @@ apiRouter.get("/thumbnail", withErrorHandling(async (req, res) => {
} }
try { try {
const response = await fetch(getInvidiousThumbnailURL(thumbnailUrl)); const thumbnailUrlWithoutLeadingSlash = thumbnailUrl.startsWith('/') ? thumbnailUrl.slice(1) : thumbnailUrl;
const response = await fetch(getInvidiousThumbnailURL(thumbnailUrlWithoutLeadingSlash));
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); throw new Error(`HTTP error! status: ${response.status}`);
} }