From eb96408d332f94ed2853da59c06cfba9bc39d69d Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Sat, 25 Sep 2021 18:45:52 +0200 Subject: [PATCH] Working clientside stuff closes #3 --- src/server.js | 312 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 286 insertions(+), 26 deletions(-) diff --git a/src/server.js b/src/server.js index 1891450..eb18644 100644 --- a/src/server.js +++ b/src/server.js @@ -113,33 +113,13 @@ fastify.get('/:shortcode', async (req, res) => { } if (isBot(req.headers['user-agent']) && target[0].no_preview) { - return ` - - - - - - - - - - - - + res.type("text/html"); + return bot_html; + } - LinkyLinky - - -

- -

LinkyLinky 🔗

-

A small url shortener, originaly developed for kauft.es

-

LinkyLinky by Kauft.es is a custom url shortener.
- You're reading this, b/c someone doesn't want their shorturl to be indexed by bots/crawlers/spiders.

-

- - - `; + if (target[0].clientside) { + res.type("text/html"); + return clientside_html.replace("{{targeturl}}", target[0].target) } res.redirect(302, target[0].target); @@ -479,6 +459,286 @@ async function validate(username, password, req, reply) { req.user = username; } +const bot_html = ` + + + + + + + + + + + + + LinkyLinky + + +

+ +

LinkyLinky 🔗

+

A small url shortener, originaly developed for kauft.es

+

LinkyLinky by Kauft.es is a custom url shortener.
+ You're reading this, b/c someone doesn't want their shorturl to be indexed by bots/crawlers/spiders.

+

+ + + `; + +const clientside_html = ` + + + + + + + + + + + + +
+
+
+

kauft.es

+
+
+

kauft.es

+
+
+

kauft.es

+
+
+

kauft.es

+
+
+

kauft.es

+
+
+

kauft.es

+
+
+
+ + + + + +`; + // Run the server! const start = async () => { try {