From c24f30f5ecb4d5f7c15f0c79f4c8d54945635417 Mon Sep 17 00:00:00 2001 From: Adrian Vollmer Date: Sun, 16 Oct 2022 18:30:09 +0200 Subject: [PATCH] Fix error with about:srcdoc links; add extra check --- zundler/assets/inject_post.js | 3 ++- zundler/assets/main.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/zundler/assets/inject_post.js b/zundler/assets/inject_post.js index cb7cc47..37296e1 100644 --- a/zundler/assets/inject_post.js +++ b/zundler/assets/inject_post.js @@ -91,7 +91,7 @@ var fix_link = function(a) { a.addEventListener('click', virtual_click); } else if (a.getAttribute('href').startsWith('#')) { a.setAttribute('href', "about:srcdoc" + a.getAttribute('href')) - } else { + } else if (!a.getAttribute('href').startsWith('about:srcdoc')) { // External links should open in a new tab. Browsers block links to // sites of different origin within an iframe for security reasons. a.setAttribute('target', "_blank"); @@ -144,6 +144,7 @@ var is_virtual = function(url) { _url.startsWith('https://') || _url.startsWith('http://') || _url.startsWith('data:') || + _url.startsWith('about:srcdoc') || _url.startsWith('blob:') )); }; diff --git a/zundler/assets/main.js b/zundler/assets/main.js index 6f8d205..f7979d6 100644 --- a/zundler/assets/main.js +++ b/zundler/assets/main.js @@ -38,6 +38,12 @@ var load_virtual_page = (function (path, get_params, anchor) { const file = window.global_context.file_tree[path]; var iframe = createIframe(); + if (!file) { + console.error("File not found:", path, get_params, anchor); + return false; + } + + const data = file.data; window.global_context.get_parameters = get_params; if (file.mime_type == 'text/html') {