Skip to content

Commit 313a07e

Browse files
committed
feat: use url template in followUrl
1 parent 71ef6fb commit 313a07e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/botkit/src/pages.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from "@fedify/fedify/vocab";
2929
import { Hono } from "hono";
3030
import { decode } from "html-entities";
31+
import { parseTemplate } from "url-template";
3132
import type { BotImpl } from "./bot-impl.ts";
3233
import { FollowButton } from "./components/FollowButton.tsx";
3334
import { Follower } from "./components/Follower.tsx";
@@ -463,10 +464,10 @@ app.post("/follow", async (c) => {
463464

464465
if (subscribeLink?.template) {
465466
const botActorUri = ctx.getActorUri(bot.identifier);
466-
const followUrl = subscribeLink.template.replace(
467-
"{uri}",
468-
encodeURIComponent(botActorUri.href),
469-
);
467+
const followUrlTemplate = parseTemplate(subscribeLink.template);
468+
const followUrl = followUrlTemplate.expand({
469+
uri: botActorUri.href,
470+
});
470471
return c.redirect(followUrl);
471472
}
472473

0 commit comments

Comments
 (0)