From 77d942ac0ef07cc0ac55c9d1b05071f38d064e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20V=C3=A1clav=C3=ADk?= Date: Sat, 4 Jan 2025 13:27:19 +0100 Subject: [PATCH] Gallery: Support different URL variants on wikimedia commons --- src/services/images/getCommonsImageUrl.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/images/getCommonsImageUrl.ts b/src/services/images/getCommonsImageUrl.ts index 6c97ad7a5..2d434743e 100644 --- a/src/services/images/getCommonsImageUrl.ts +++ b/src/services/images/getCommonsImageUrl.ts @@ -11,7 +11,9 @@ export const getCommonsImageUrl = ( console.warn('Invalid Commons photo name without "File:":', photoName); return null; } - const fileName = photoName.replace(/^File:/, '').replace(/ /g, '_'); + const fileName = decodeURI(photoName) + .replace(/^.*File:/, '') + .replace(/ /g, '_'); const hash = md5(fileName); const part1 = hash[0]; const part2 = hash.substring(0, 2);