Skip to content
This repository was archived by the owner on Oct 4, 2025. It is now read-only.

Commit a3f0790

Browse files
authored
favicon for IPFS publish: load from local path + catch null icon (#6)
* ipfs serialize: fix serializing if no favicon found * load icon.png from local path as well
1 parent 104a237 commit a3f0790

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webrecorder/awp-sw",
33
"browser": "dist/sw.js",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"main": "index.js",
66
"type": "module",
77
"repository": {
@@ -18,7 +18,7 @@
1818
"dependencies": {
1919
"@ipld/car": "^5.1.1",
2020
"@ipld/unixfs": "^2.1.1",
21-
"@webrecorder/wabac": "^2.16.1",
21+
"@webrecorder/wabac": "^2.16.2",
2222
"auto-js-ipfs": "^2.3.0",
2323
"client-zip": "^2.3.0",
2424
"hash-wasm": "^4.9.0",

src/ipfsutils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ export async function ipfsAdd(coll, downloaderOpts = {}, replayOpts = {}, progre
6363
UnixFS.withCapacity(capacity)
6464
);
6565

66-
const swContent = await fetchBuffer("sw.js", replayOpts.replayBaseUrl || self.location.href);
67-
const uiContent = await fetchBuffer("ui.js", replayOpts.replayBaseUrl || self.location.href);
66+
const baseUrl = replayOpts.replayBaseUrl || self.location.href;
67+
68+
const swContent = await fetchBuffer("sw.js", baseUrl);
69+
const uiContent = await fetchBuffer("ui.js", baseUrl);
6870

6971
let favicon = null;
7072

7173
try {
72-
favicon = await fetchBuffer("https://replayweb.page/build/icon.png");
74+
favicon = await fetchBuffer("icon.png", baseUrl);
7375
} catch (e) {
7476
console.warn("Couldn't load favicon");
7577
}
@@ -80,7 +82,7 @@ export async function ipfsAdd(coll, downloaderOpts = {}, replayOpts = {}, progre
8082

8183
if (coll.config && coll.config.metadata && coll.config.metadata.size) {
8284
totalSize = coll.config.metadata.size +
83-
swContent.length + uiContent.length + favicon.length + htmlContent.length;
85+
swContent.length + uiContent.length + (favicon ? favicon.length : 0) + htmlContent.length;
8486
}
8587

8688
progress(0, totalSize);

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,10 @@
512512
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.0.tgz#f08ea194e01ed45379383a8886e8c85a65a5f26a"
513513
integrity sha512-Rumq5mHvGXamnOh3O8yLk1sjx8dB30qF1OeR6VC00DIR6SLJ4bwwUGKC4pE7qBFoQyyh0H9sAg3fikYgAqVR0w==
514514

515-
"@webrecorder/wabac@^2.16.1":
516-
version "2.16.1"
517-
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.16.1.tgz#85c0bab4d45975d8ecfbdb57e5735a093b728410"
518-
integrity sha512-sd2t96hEgDo2eP9M2nA4jYP0bFh3cslncvjrOC+5QnE2cpoEqyfZv6dm8dkhaAy0toOhwLzbbhzLaTb5kkh63g==
515+
"@webrecorder/wabac@^2.16.2":
516+
version "2.16.2"
517+
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.16.2.tgz#0e224d62e63aeada25ec542635b0bab5f36869b5"
518+
integrity sha512-duTfM2EEvSb9ytZDkAB6zOwR1/EtmtJaMNyIgwnTDkvPWyMAEoD3M5LGshNW9W3igVJLwZVbJ7C9j63PAFDiMQ==
519519
dependencies:
520520
"@peculiar/asn1-ecc" "^2.3.4"
521521
"@peculiar/asn1-schema" "^2.3.3"

0 commit comments

Comments
 (0)