Skip to content

Commit 324ba2a

Browse files
authored
ensure about:blank pages are never recorded! (#329)
- don't cache pageinfo if nothing added, use isEmptyPage() check - exclude about:blank / no-timestamp pageinfo from being added - bump to 0.15.9 - fixes #314
1 parent 507d250 commit 324ba2a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webrecorder/archivewebpage",
33
"productName": "ArchiveWeb.page",
4-
"version": "0.15.8",
4+
"version": "0.15.9",
55
"main": "index.js",
66
"description": "Create Web Archives directly in your browser",
77
"repository": {

src/recorder.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class Recorder {
368368
}
369369

370370
// @ts-expect-error - TS2339 - Property '_cachePageInfo' does not exist on type 'Recorder'.
371-
if (this._cachePageInfo) {
371+
if (!this.isEmptyPage(this._cachePageInfo)) {
372372
// @ts-expect-error - TS2339 - Property '_doAddPage' does not exist on type 'Recorder'. | TS2339 - Property '_cachePageInfo' does not exist on type 'Recorder'.
373373
await this._doAddPage(this._cachePageInfo);
374374
// @ts-expect-error - TS2339 - Property '_cachePageInfo' does not exist on type 'Recorder'.
@@ -1107,10 +1107,9 @@ class Recorder {
11071107

11081108
// @ts-expect-error - TS7006 - Parameter 'currPage' implicitly has an 'any' type. | TS7006 - Parameter 'domSnapshot' implicitly has an 'any' type. | TS7006 - Parameter 'finished' implicitly has an 'any' type.
11091109
commitPage(currPage, domSnapshot, finished) {
1110-
if (!currPage?.url || !currPage.ts || currPage.url === "about:blank") {
1110+
if (this.isEmptyPage(currPage)) {
11111111
return;
11121112
}
1113-
11141113
if (domSnapshot) {
11151114
currPage.text = this.parseTextFromDOMSnapshot(domSnapshot);
11161115
} else if (!currPage.text) {
@@ -1147,12 +1146,14 @@ class Recorder {
11471146
// @ts-expect-error - TS2339 - Property 'sizeNew' does not exist on type 'Recorder'.
11481147
this.sizeNew += writtenSize;
11491148

1150-
// @ts-expect-error - TS2339 - Property '_cachePageInfo' does not exist on type 'Recorder'.
1151-
this._cachePageInfo = pageInfo;
1152-
// @ts-expect-error - TS2339 - Property '_cacheSessionTotal' does not exist on type 'Recorder'.
1153-
this._cacheSessionTotal += payloadSize;
1154-
// @ts-expect-error - TS2339 - Property '_cacheSessionNew' does not exist on type 'Recorder'.
1155-
this._cacheSessionNew += writtenSize;
1149+
if (writtenSize) {
1150+
// @ts-expect-error - TS2339 - Property '_cachePageInfo' does not exist on type 'Recorder'.
1151+
this._cachePageInfo = pageInfo;
1152+
// @ts-expect-error - TS2339 - Property '_cacheSessionTotal' does not exist on type 'Recorder'.
1153+
this._cacheSessionTotal += payloadSize;
1154+
// @ts-expect-error - TS2339 - Property '_cacheSessionNew' does not exist on type 'Recorder'.
1155+
this._cacheSessionNew += writtenSize;
1156+
}
11561157
}
11571158

11581159
// @ts-expect-error - TS7006 - Parameter 'params' implicitly has an 'any' type. | TS7006 - Parameter 'sessions' implicitly has an 'any' type.
@@ -1227,6 +1228,14 @@ class Recorder {
12271228
this.firstPageStarted = true;
12281229
}
12291230

1231+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1232+
isEmptyPage(pageInfo: any) {
1233+
if (!pageInfo?.url || !pageInfo.ts || pageInfo.url === "about:blank") {
1234+
return true;
1235+
}
1236+
return false;
1237+
}
1238+
12301239
// @ts-expect-error - TS7006 - Parameter 'url' implicitly has an 'any' type. | TS7006 - Parameter 'mime' implicitly has an 'any' type.
12311240
_initNewPage(url, mime) {
12321241
// @ts-expect-error - TS2339 - Property 'pageInfo' does not exist on type 'Recorder'.

0 commit comments

Comments
 (0)