From e14adffbc8b95088c4719c31d02c89edb9d80f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Mon, 21 Oct 2024 00:05:50 +0200 Subject: [PATCH] Allow old-school username routes with ~ --- handlers/username.ts | 2 +- main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/handlers/username.ts b/handlers/username.ts index 33c7332..c2581bb 100644 --- a/handlers/username.ts +++ b/handlers/username.ts @@ -7,7 +7,7 @@ import { profilePageHtml } from "../html.ts" const usernameHandler = async function (ctx: Context) { const { request } = ctx; - const username = ctx.params.path.replace(/^@/, '');; + const username = ctx.params.path.replace(/^(@|~)/, ""); const pubkey = await lookupPubkeyByUsername(username); if (!pubkey) { diff --git a/main.ts b/main.ts index 0f25cf7..8f322b8 100644 --- a/main.ts +++ b/main.ts @@ -16,7 +16,7 @@ router.get("/:path", async (ctx: ctx) => { await nprofileHandler(ctx); } else if (path.startsWith("npub")) { await npubHandler(ctx); - } else if (path.startsWith("@")) { + } else if (path.startsWith("@") || path.startsWith("~")) { await usernameHandler(ctx); } else { ctx.response.status = 404;