Allow old-school username routes with ~

This commit is contained in:
Râu Cao 2024-10-21 00:05:50 +02:00
parent 0e5b4b1807
commit e14adffbc8
Signed by: raucao
GPG Key ID: 37036C356E56CC51
2 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ import { profilePageHtml } from "../html.ts"
const usernameHandler = async function (ctx: Context) { const usernameHandler = async function (ctx: Context) {
const { request } = ctx; const { request } = ctx;
const username = ctx.params.path.replace(/^@/, '');; const username = ctx.params.path.replace(/^(@|~)/, "");
const pubkey = await lookupPubkeyByUsername(username); const pubkey = await lookupPubkeyByUsername(username);
if (!pubkey) { if (!pubkey) {

View File

@ -16,7 +16,7 @@ router.get("/:path", async (ctx: ctx) => {
await nprofileHandler(ctx); await nprofileHandler(ctx);
} else if (path.startsWith("npub")) { } else if (path.startsWith("npub")) {
await npubHandler(ctx); await npubHandler(ctx);
} else if (path.startsWith("@")) { } else if (path.startsWith("@") || path.startsWith("~")) {
await usernameHandler(ctx); await usernameHandler(ctx);
} else { } else {
ctx.response.status = 404; ctx.response.status = 404;