Allow old-school username routes with ~
This commit is contained in:
parent
0e5b4b1807
commit
e14adffbc8
@ -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) {
|
||||||
|
2
main.ts
2
main.ts
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user