Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for over-encoded URLs in zimit2 #1230

Merged
merged 8 commits into from
May 1, 2024
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
Loading