Skip to content

Commit

Permalink
wacz replay: fix redirect loop on 404 (#125)
Browse files Browse the repository at this point in the history
* wacz replay: fix redirect loop, use different var for foundHash vs
existing hash to avoid redirecting to the same URL
fixes webrecorder/replayweb.page#184

* bump version to 2.16.2
  • Loading branch information
ikreymer committed Jun 20, 2023
1 parent 702a609 commit 989082a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/sw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wabac",
"version": "2.16.1",
"version": "2.16.2",
"main": "index.js",
"type": "module",
"license": "AGPL-3.0-or-later",
Expand Down
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 989082a

Please sign in to comment.