commit 61a7791bc68e3098832fe98d11e58f6e74c0b71b
parent 886801f58d90cc1e3309d72fc392646895c2a5a3
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 27 Oct 2021 18:06:09 -0700
handle not found links
Diffstat:
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/index.js b/index.js
@@ -105,9 +105,12 @@ async function handle_request(req, res)
 
 	const indreq = req.path.match(/^\/([^/]+)\/?$/)
 	if (indreq) {
-		const gmi = await make_index_request(indreq[1], "/" + indreq[1])
-		res.end(gmi)
-		return
+		try {
+			const gmi = await make_index_request(indreq[1], "/" + indreq[1])
+			return res.end(gmi)
+		} catch (e) {
+			return res.notFound()
+		}
 	}
 
 	const pathreq = req.path.match(/\/([^/]+)\/(.*)$/)
@@ -117,9 +120,12 @@ async function handle_request(req, res)
 	const slug = pathreq[2]
 
 	const url = host + "/" + slug + ".json"
-	const gmi = await make_request(url, "/" + host)
-
-	res.end(gmi)
+	try {
+		const gmi = await make_request(url, "/" + host)
+		return res.end(gmi)
+	} catch (e) {
+		return res.notFound()
+	}
 }
 
 function serve(opts)