From f5895e94106255ec8f2eb28f40ea7971dec49880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Wed, 15 Nov 2023 12:20:41 +0100 Subject: [PATCH] catch ERR_INVALID_URL closes #170 --- src/preview.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/preview.ts b/src/preview.ts index e4872209c..03ccab78b 100644 --- a/src/preview.ts +++ b/src/preview.ts @@ -45,9 +45,9 @@ class Server { _handleRequest: RequestListener = async (req, res) => { console.log(req.method, req.url); - const url = new URL(req.url!, "http://localhost"); - let {pathname} = url; try { + const url = new URL(req.url!, "http://localhost"); + let {pathname} = url; if (pathname === "/_observablehq/runtime.js") { send(req, "/@observablehq/runtime/dist/runtime.js", {root: "./node_modules"}).pipe(res); } else if (pathname.startsWith("/_observablehq/")) {