about summary refs log tree commit diff
path: root/bskylink
diff options
context:
space:
mode:
authorHailey <me@haileyok.com>2025-03-20 15:08:54 -0700
committerGitHub <noreply@github.com>2025-03-20 15:08:54 -0700
commit52429b651f8e343112b3250df40c95d3e82eba5e (patch)
treeb0772316f396b0d535e5f711ef62817137fe810f /bskylink
parent0e658dbdfdd4e6ece53ee04caf93d596034be587 (diff)
downloadvoidsky-52429b651f8e343112b3250df40c95d3e82eba5e.tar.zst
blink: use meta for redirect (#8031)
* try using meta

* color scheme

* revert test change

* escape
Diffstat (limited to 'bskylink')
-rw-r--r--bskylink/package.json2
-rw-r--r--bskylink/src/routes/redirect.ts10
-rw-r--r--bskylink/yarn.lock7
3 files changed, 16 insertions, 3 deletions
diff --git a/bskylink/package.json b/bskylink/package.json
index 5fdee206b..21fe123ab 100644
--- a/bskylink/package.json
+++ b/bskylink/package.json
@@ -9,8 +9,10 @@
   },
   "dependencies": {
     "@atproto/common": "^0.4.0",
+    "@types/escape-html": "^1.0.4",
     "body-parser": "^1.20.2",
     "cors": "^2.8.5",
+    "escape-html": "^1.0.3",
     "express": "^4.19.2",
     "http-terminator": "^3.2.0",
     "kysely": "^0.27.3",
diff --git a/bskylink/src/routes/redirect.ts b/bskylink/src/routes/redirect.ts
index 4e7052af7..519fe52a0 100644
--- a/bskylink/src/routes/redirect.ts
+++ b/bskylink/src/routes/redirect.ts
@@ -1,6 +1,7 @@
 import assert from 'node:assert'
 
 import {DAY, SECOND} from '@atproto/common'
+import escapeHTML from 'escape-html'
 import {Express} from 'express'
 
 import {AppContext} from '../context.js'
@@ -40,8 +41,13 @@ export default function (ctx: AppContext, app: Express) {
       }
 
       res.setHeader('Cache-Control', `max-age=${(7 * DAY) / SECOND}`)
-      res.setHeader('Location', url.href)
-      return res.status(301).end()
+      res.type('html')
+      res.status(200)
+
+      const escaped = escapeHTML(url.href)
+      return res.send(
+        `<html><head><meta http-equiv="refresh" content="0; URL='${escaped}'" /><style>:root { color-scheme: light dark; }</style></head></html>`,
+      )
     }),
   )
 }
diff --git a/bskylink/yarn.lock b/bskylink/yarn.lock
index d2fa31456..e72fea0b9 100644
--- a/bskylink/yarn.lock
+++ b/bskylink/yarn.lock
@@ -69,6 +69,11 @@
   dependencies:
     "@types/node" "*"
 
+"@types/escape-html@^1.0.4":
+  version "1.0.4"
+  resolved "https://registry.yarnpkg.com/@types/escape-html/-/escape-html-1.0.4.tgz#dc7c166b76c7b03b27e32f80edf01d91eb5d9af2"
+  integrity sha512-qZ72SFTgUAZ5a7Tj6kf2SHLetiH5S6f8G5frB2SPQ3EyF02kxdyBFf4Tz4banE3xCgGnKgWLt//a6VuYHKYJTg==
+
 "@types/node@*":
   version "20.14.2"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.2.tgz#a5f4d2bcb4b6a87bffcaa717718c5a0f208f4a18"
@@ -276,7 +281,7 @@ es-errors@^1.3.0:
   resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f"
   integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==
 
-escape-html@~1.0.3:
+escape-html@^1.0.3, escape-html@~1.0.3:
   version "1.0.3"
   resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
   integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==