aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
authorJoe Mou <dev@mou.fo>2026-04-25 13:35:17 -0400
committerJoe Mou <dev@mou.fo>2026-04-28 02:07:40 -0400
commit0d8911577ba3d49df3577d686837541a9aee69bd (patch)
tree638be4b23ee14a30fa895d11ccdf2d3779c56b32 /src/index.ts
parentf179a3f77c6617b4375e6149cc696ae5dab4d171 (diff)
Support redirects
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts
index 59c98ee..eb3a0ee 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -14,6 +14,7 @@ import {
getGitHubRepo,
getGitHubTree,
GitHubHTTPError,
+ RedirectError,
} from "./scraper.ts";
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
@@ -32,7 +33,9 @@ async function tryRender<T extends object>(c: Context, template: string, promise
try {
data = await promise;
} catch (e) {
- if (e instanceof GitHubHTTPError) {
+ if (e instanceof RedirectError) {
+ return c.redirect(e.location);
+ } else if (e instanceof GitHubHTTPError) {
c.status(e.status as StatusCode);
const message = `GitHub responded with HTTP ${e.status} ${e.message}`;
return c.html(await eta.renderAsync("error.eta", { title: e.message, message }));