Skip to content

Commit

Permalink
Gallery: Support different URL variants on wikimedia commons
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik committed Jan 4, 2025
1 parent 6138132 commit 77d942a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/services/images/getCommonsImageUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 77d942a

Please sign in to comment.