Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

Commit d90bd16

Browse files
committed
Handle webview events without data
1 parent 686325d commit d90bd16

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/webview-ext-common.ts

+4
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ export class WebViewExtBase extends View {
350350
filepath = fs.path.normalize(fs.knownFolders.currentApp().path + filepath.substr(1));
351351
}
352352

353+
if (filepath.startsWith('file://')) {
354+
filepath = filepath.replace(/^file:\/\//, '');
355+
}
356+
353357
if (!fs.File.exists(filepath)) {
354358
console.error(`WebViewExt.resolveLocalResourceFilePath("${filepath}") - no such file`);
355359
return;

src/webview-ext.android.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ function initializeWebViewClient(): void {
235235
return;
236236
}
237237

238-
owner.onWebViewEvent(eventName, JSON.parse(data));
238+
try {
239+
owner.onWebViewEvent(eventName, JSON.parse(data));
240+
return;
241+
} catch {
242+
}
243+
owner.onWebViewEvent(eventName, data);
239244
}
240245
}
241246

0 commit comments

Comments
 (0)