Skip to content

Commit

Permalink
replay fixes: (#217)
Browse files Browse the repository at this point in the history
- ensure <base> URL is resolved internally as unrewritten, if already rewritten
- bump to 2.20.8
  • Loading branch information
ikreymer authored Dec 31, 2024
1 parent e9a15d2 commit b4fbd6b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wabac",
"version": "2.20.7",
"version": "2.20.8",
"main": "index.js",
"type": "module",
"exports": {
Expand Down Expand Up @@ -38,7 +38,7 @@
"path-parser": "^6.1.0",
"process": "^0.11.10",
"stream-browserify": "^3.0.0",
"warcio": "^2.4.2"
"warcio": "^2.4.3"
},
"devDependencies": {
"@swc-node/register": "^1.10.9",
Expand Down
10 changes: 10 additions & 0 deletions src/rewrite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class Rewriter {
decode: boolean;

prefix: string;
originPrefix = "";
relPrefix = "";
schemeRelPrefix = "";
scheme: string;
Expand Down Expand Up @@ -109,6 +110,7 @@ export class Rewriter {
this.prefix = prefix || "";
if (this.prefix && urlRewrite) {
const parsed = new URL(this.prefix);
this.originPrefix = parsed.origin;
this.relPrefix = parsed.pathname;
this.schemeRelPrefix = this.prefix.slice(parsed.protocol.length);
}
Expand Down Expand Up @@ -351,6 +353,14 @@ export class Rewriter {
}

updateBaseUrl(url: string) {
// if already rewritten, unrewrite first
if (this.originPrefix && url.startsWith(this.originPrefix)) {
const inx = url.indexOf("/http");
if (inx >= 0) {
url = url.slice(inx + 1);
}
}

// set internal base to full url
this.baseUrl = new URL(url, this.baseUrl).href;

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3764,10 +3764,10 @@ warcio@^2.4.0:
uuid-random "^1.3.2"
yargs "^17.7.2"

warcio@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/warcio/-/warcio-2.4.2.tgz#782d8dcb0769f271b0ae96521fb4969e2570e9b3"
integrity sha512-QYbZ3EGYtnAIrzL7Bajo7ak87pipilpkIfaFIzFQWUX4wuXNuKqnfQy/EAoi2tEIl3VJgsWcL+wjjk4+15MKbQ==
warcio@^2.4.3:
version "2.4.3"
resolved "https://registry.yarnpkg.com/warcio/-/warcio-2.4.3.tgz#37ff95c2358d0d5ddb16e924fe200c4774b3903d"
integrity sha512-c397HNfLE7yJsyVF3XKXB+Yh3q3WKljhdYRPkKF9eyZMtB+HIxj1aBqgq0nTYz492KMKtzygBo0Gx+Gi0fJ9dg==
dependencies:
"@types/pako" "^1.0.7"
"@types/stream-buffers" "^3.0.7"
Expand Down

0 comments on commit b4fbd6b

Please sign in to comment.