From c0529307fae5ec8744a89f19fa4e2bfc0d619546 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 14 Mar 2023 08:58:52 -0400 Subject: [PATCH] Properly handle failed fetches in code viewer --- src/js/code-viewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/code-viewer.js b/src/js/code-viewer.js index b94756665..e782809d0 100644 --- a/src/js/code-viewer.js +++ b/src/js/code-viewer.js @@ -105,9 +105,9 @@ async function fetchResource(url) { response = await fetch(url, fetchOptions); text = await response.text(); } catch(reason) { - text = reason; + text = String(reason); } - let mime = response.headers.get('Content-Type') || ''; + let mime = response && response.headers.get('Content-Type') || ''; mime = mime.replace(/\s*;.*$/, '').trim(); const beautifierOptions = { 'end_with_newline': true,