diff --git a/src/uv.sw.js b/src/uv.sw.js index d02cacb..1bcd6e9 100644 --- a/src/uv.sw.js +++ b/src/uv.sw.js @@ -285,7 +285,7 @@ class UVServiceWorker extends Ultraviolet.EventEmitter { console.error(err); - return renderError(err, fetchedURL, this.address); + return renderError(err, fetchedURL); } } static Ultraviolet = Ultraviolet; @@ -390,178 +390,75 @@ class HookEvent { /** * - * @param {string} fetchedURL - * @param {string} bareServer - * @returns - */ -function hostnameErrorTemplate(fetchedURL, bareServer) { - const parsedFetchedURL = new URL(fetchedURL); - const script = - `remoteHostname.textContent = ${JSON.stringify( - parsedFetchedURL.hostname - )};` + - `bareServer.href = ${JSON.stringify(bareServer)};` + - `uvHostname.textContent = ${JSON.stringify(location.hostname)};` + - `reload.addEventListener("click", () => location.reload());` + - `uvVersion.textContent = ${JSON.stringify( - process.env.ULTRAVIOLET_VERSION - )};`; - - return ( - '' + - '' + - '
' + - "" + - '’s server IP address could not be found.
' + - 'Try:
' + - 'Ultraviolet v
' + - `` + - '' + - '' - ); -} - -/** - * - * @param {string} title - * @param {string} code - * @param {string} id - * @param {string} message * @param {string} trace * @param {string} fetchedURL - * @param {string} bareServer * @returns */ function errorTemplate( - title, - code, - id, - message, trace, fetchedURL, - bareServer ) { - // produced by bare-server-node - if (message === 'The specified host could not be resolved.') - return hostnameErrorTemplate(fetchedURL, bareServer); - // turn script into a data URI so we don't have to escape any HTML values - const script = - `errorTitle.textContent = ${JSON.stringify(title)};` + - `errorCode.textContent = ${JSON.stringify(code)};` + - (id ? `errorId.textContent = ${JSON.stringify(id)};` : '') + - `errorMessage.textContent = ${JSON.stringify(message)};` + - `errorTrace.value = ${JSON.stringify(trace)};` + - `fetchedURL.textContent = ${JSON.stringify(fetchedURL)};` + - `bareServer.href = ${JSON.stringify(bareServer)};` + - `for (const node of document.querySelectorAll("#uvHostname")) node.textContent = ${JSON.stringify( + const script = ` + errorTrace.value = ${JSON.stringify(trace)}; + fetchedURL.textContent = ${JSON.stringify(fetchedURL)}; + for (const node of document.querySelectorAll("#uvHostname")) node.textContent = ${JSON.stringify( location.hostname - )};` + - `reload.addEventListener("click", () => location.reload());` + - `uvVersion.textContent = ${JSON.stringify( + )}; + reload.addEventListener("click", () => location.reload()); + uvVersion.textContent = ${JSON.stringify( process.env.ULTRAVIOLET_VERSION - )};`; + )}; + ` return ( - '' + - '' + - '' + - "" + - 'Failed to load
' + - '' + - 'Code: | |
ID: |
Try:
' + - 'If you\'re the administrator of , try:
' + - 'Ultraviolet v
' + - `` + - '' + - '' + }"> +