Skip to content

Commit

Permalink
Workaround for over-encoded URLs in zimit2 #1229 (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid authored May 1, 2024
1 parent c455850 commit 85a9d82
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,10 @@ function handleClickOnReplayLink (ev, anchor) {
} else {
zimUrl = pseudoNamespace + pseudoDomainPath + anchor.search;
}
// It is necessary to fully decode zimit2, as these archives follow OpenZIM spec
if (params.zimType === 'zimit2') {
zimUrl = decodeURIComponent(zimUrl);
}
// We need to test the ZIM link
if (zimUrl) {
ev.preventDefault();
Expand Down Expand Up @@ -2355,9 +2359,12 @@ function handleMessageChannelMessage (event) {
// We received a message from the ServiceWorker
// The ServiceWorker asks for some content
var title = event.data.title;
if (selectedArchive.zimType === 'zimit') {
// Zimit ZIMs store assets with the querystring, so we need to add it!
if (appstate.isReplayWorkerAvailable) {
// Zimit ZIMs store assets with the querystring, so we need to add it. ReplayWorker handles encoding.
title = title + event.data.search;
} else if (params.zimType === 'zimit') {
// Zimit classic ZIMs store assets encoded with the querystring, so we need to add it
title = encodeURI(title) + event.data.search;
}
var messagePort = event.ports[0];
var readFile = function (dirEntry) {
Expand Down

0 comments on commit 85a9d82

Please sign in to comment.