Skip to content

Commit

Permalink
wacz replay: fix redirect loop, use different var for foundHash vs
Browse files Browse the repository at this point in the history
existing hash to avoid redirecting to the same URL
fixes webrecorder/replayweb.page#184
  • Loading branch information
ikreymer committed Jun 20, 2023
1 parent 702a609 commit 3e10dc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/sw.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/wacz/multiwacz.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,8 @@ export class MultiWACZ extends OnDemandPayloadArchiveDB// implements WACZLoadSou
return resp;
}

let foundHash = null;

for (const [name, file] of Object.entries(this.waczfiles)) {
if (file.fileType !== WACZ_LEAF) {
continue;
Expand All @@ -755,13 +757,13 @@ export class MultiWACZ extends OnDemandPayloadArchiveDB// implements WACZLoadSou
resp = await super.getResource(request, prefix, event, {waczname: name, noFuzzyCheck: true});
if (resp) {
waczname = name;
hash = file.hash;
foundHash = file.hash;
break;
}
}

if (waczname) {
return Response.redirect(`${prefix}:${hash}/${request.timestamp}mp_/${request.url}`);
return Response.redirect(`${prefix}:${foundHash}/${request.timestamp}mp_/${request.url}`);
}

if (this.fuzzyUrlRules.length) {
Expand Down

0 comments on commit 3e10dc4

Please sign in to comment.