Properly handle failed fetches in code viewer

This commit is contained in:
Raymond Hill 2023-03-14 08:58:52 -04:00
parent 0ba5ec162b
commit c0529307fa
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 2 additions and 2 deletions

View File

@ -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,