summaryrefslogtreecommitdiff
path: root/cgithub/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
commitcfe74db6c177151da3d1bc8549732e3d39448040 (patch)
tree49359a8587e87b2bc857d0a7b7fc1c3c396cde86 /cgithub/src/index.ts
parentdbe8141dce07559c1e16f17800dfd505b0ecdb46 (diff)
Support redirects
Diffstat (limited to 'cgithub/src/index.ts')
-rw-r--r--cgithub/src/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/cgithub/src/index.ts b/cgithub/src/index.ts
index 59c98ee..eb3a0ee 100644
--- a/cgithub/src/index.ts
+++ b/cgithub/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 }));