diff --git a/dist/404.html b/dist/404.html
new file mode 100644
index 0000000..4cd37c4
--- /dev/null
+++ b/dist/404.html
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+ Blaze - 404
+
+
+
+ 404
+
+ Go back
+
+
diff --git a/index.ts b/index.ts
index c09b20b..1220dec 100644
--- a/index.ts
+++ b/index.ts
@@ -4,7 +4,7 @@ import got from "got";
import path from "path";
import { fileURLToPath } from "url";
import "dotenv/config";
-import { parseHTML } from "linkedom";
+import { parseHTML, parseJSON } from "linkedom";
// @ts-ignore
import XHR2 from "xhr2";
const XMLHttpRequest = XHR2.XMLHttpRequest;
@@ -111,7 +111,30 @@ app.get("/blazed", async (req, res) => {
headers: { Accept: "text/html" },
});
const { document } = parseHTML(response.body);
+
+ // TODO: missing handling of 404. The idea is to send the blaze 404 page, otherwise will show error page on client
+
if (!isProbablyReaderable(document)) {
+ // TODO: send minimalized version of the page instead the read mode
+ // implementation draft:
+ // document.querySelectorAll("link").forEach((l) => {
+ // l.remove();
+ // });
+
+ // document.querySelectorAll("style").forEach((s) => {
+ // s.remove;
+ // });
+
+ // document.querySelectorAll("script").forEach((s) => {
+ // s.remove();
+ // });
+
+ // // @ts-ignore
+ // const jsonDocument = document.toJSON();
+
+ // const cleanDocument = parseJSON(jsonDocument);
+ // return res.send(document.toString());
+
return res.sendFile(path.join(__dirname, "/dist/not_blazed.html"));
}
@@ -135,7 +158,8 @@ app.get("/blazed", async (req, res) => {