From 47a4d1af9bc7dee1312017cf55e912f8ae9c6bd8 Mon Sep 17 00:00:00 2001 From: Eric McCarthy Date: Fri, 22 Nov 2024 05:24:43 +0000 Subject: [PATCH] fix: add missing mastodon profile redirect This is needed for GitHub profile mastodon link to work. --- infra.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/infra.yaml b/infra.yaml index b6d6229..29fa203 100644 --- a/infra.yaml +++ b/infra.yaml @@ -210,6 +210,7 @@ Resources: FunctionCode: !Sub | const needsIndexHtmlRe = /(\/[^\/.]+)\/*$/ const penumbraJournalRedirectRe = /^\/penumbra\/journal\/00[1-5]-/ + const mastodonProfileRedirectRe = /^\/@eric\/?/ function handler(event) { const request = event.request @@ -239,6 +240,18 @@ Resources: } } + if (mastodonProfileRedirectRe.test(request.uri)) { + return { + statusCode: 302, + statusDescription: 'Found', + headers: { + location: { + value: 'https://mastodon.limulus.net' + request.uri + } + } + } + } + request.uri = request.uri.replace(needsIndexHtmlRe, '$1/index.html') return request }