Skip to content

Commit

Permalink
rewriting: handle new blob:<id>/<base url> scheme to support setting …
Browse files Browse the repository at this point in the history
…the base url for blob: based rewriting (#114)

deps: update to wombat 3.5.1 for new blob rewriting
  • Loading branch information
ikreymer authored Apr 6, 2023
1 parent f453c2a commit 231d0ed
Show file tree
Hide file tree
Showing 6 changed files with 1,019 additions and 130 deletions.
1,091 changes: 970 additions & 121 deletions dist/sw.js

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion dist/wombat.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion dist/wombatWorkers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@peculiar/asn1-ecc": "^2.3.4",
"@peculiar/asn1-schema": "^2.3.3",
"@peculiar/x509": "^1.9.2",
"@webrecorder/wombat": "^3.5.0",
"@webrecorder/wombat": "^3.5.1",
"auto-js-ipfs": "^2.1.0",
"base64-js": "^1.5.1",
"brotli": "^1.3.3",
Expand Down
14 changes: 12 additions & 2 deletions src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,22 @@ class Collection {

// exact or fuzzy match
let response = null;

let baseUrl = requestURL;

try {
if (requestURL.startsWith("srcdoc:")) {
response = this.getSrcDocResponse(requestURL, requestURL.slice("srcdoc:".length));
} else if (requestURL.startsWith("blob:")) {
response = await this.getBlobResponse(requestURL);
// the form of this url is now blob:<blob id>/<base url>
// split on / to separate <blob id> and <base url>
const inx = requestURL.indexOf("/");
// blob url = blob:<origin>/<blob id>
// skip blob prefix also
const blobId = requestURL.slice(5, inx);
const blobUrl = `blob:${self.location.origin}/${blobId}`;
baseUrl = requestURL.slice(inx + 1);
response = await this.getBlobResponse(blobUrl);
} else if (requestURL === "about:blank") {
response = await this.getSrcDocResponse(requestURL);
} else if (requestURL === "__wb_module_decl.js") {
Expand Down Expand Up @@ -151,7 +161,7 @@ class Collection {
const prefix = basePrefixTS + mod + "/";

const rewriteOpts = {
baseUrl: requestURL,
baseUrl,
responseUrl: response.url,
prefix,
headInsertFunc,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.5.2.tgz#ea584b637ff63c5a477f6f21604b5a205b72c9ec"
integrity sha512-vgJ5OLWadI8aKjDlOH3rb+dYyPd2GTZuQC/Tihjct6F9GpXGZINo3Y/IVuZVTM1eDQB+/AOsjPUWH/WySDaXvw==

"@webrecorder/wombat@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@webrecorder/wombat/-/wombat-3.5.0.tgz#e48e580161a0c82f39bb92fc0c81db04c5098b8a"
integrity sha512-ID9tbsqdyhWTBukBF/epztpmgqBkjCoKc3dws7VbUDUMnvkUOIRb9uLBzvKNSg9paGJKhIYzZBtjIQLFw8gFDg==
"@webrecorder/wombat@^3.5.1":
version "3.5.1"
resolved "https://registry.yarnpkg.com/@webrecorder/wombat/-/wombat-3.5.1.tgz#2b7807d531b2d0d813b55422ade6862d22803991"
integrity sha512-LhclaHqt5p9909/5vbnHMcBZDrg/+FUauyrhGYXdBdoHLy9a0ImLHQTi2kPVrO04JQIAJwhiBi0Fz13TX+6SVg==
dependencies:
warcio "^2.0.1"

Expand Down

0 comments on commit 231d0ed

Please sign in to comment.