diff --git a/src/embed/status.ts b/src/embed/status.ts index e4f39d3..ca50b7d 100644 --- a/src/embed/status.ts +++ b/src/embed/status.ts @@ -194,6 +194,8 @@ export const handleStatus = async ( } } + console.log('translation', tweet.translation) + /* This Tweet has a translation attached to it, so we'll render it. */ if (tweet.translation) { const { translation } = tweet; diff --git a/src/realms/twitter/router.ts b/src/realms/twitter/router.ts index 73b51d7..de22204 100644 --- a/src/realms/twitter/router.ts +++ b/src/realms/twitter/router.ts @@ -29,40 +29,69 @@ export const getBaseRedirectUrl = (c: Context) => { /* Workaround for some dumb maybe-build time issue where statusRequest isn't ready or something because none of these trigger*/ const tweetRequest = async (c: Context) => await statusRequest(c); const _profileRequest = async (c: Context) => await profileRequest(c); +/* How can hono not handle trailing slashes? This is so stupid, -twitter.get('/:endpoint{status(es)?}/:id{.+}/:language{[a-z]+}?', tweetRequest); -twitter.get('/:endpoint{status(es)?}/:id{.+}/', tweetRequest); +serious TODO: Figure out how to make this not stupid. */ +twitter.get('/:endpoint{status(es)?}/:id', tweetRequest); +twitter.get('/:endpoint{status(es)?}/:id/', tweetRequest); +twitter.get('/:endpoint{status(es)?}/:id/:language/', tweetRequest); +twitter.get('/:endpoint{status(es)?}/:id/:language', tweetRequest); twitter.get( - '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:language{[a-z]+}?', - tweetRequest -); -twitter.get('/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/', tweetRequest); -twitter.get( - '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:language{[a-z]+}?', + '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language', tweetRequest ); twitter.get( - '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/', + '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language/', + tweetRequest +); +twitter.get('/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id', tweetRequest); +twitter.get('/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/', tweetRequest); +twitter.get( + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language', tweetRequest ); twitter.get( - '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/', + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:language/', tweetRequest ); twitter.get( - '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language{[a-z]+}?', + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id', tweetRequest ); twitter.get( - '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/', + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/', tweetRequest ); twitter.get( - '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language{[a-z]+}?', + '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}', tweetRequest ); twitter.get( - '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id{.+}/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/', + '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/', + tweetRequest +); +twitter.get( + '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language', + tweetRequest +); +twitter.get( + '/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language/', + tweetRequest +); +twitter.get( + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}', + tweetRequest +); +twitter.get( + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/', + tweetRequest +); +twitter.get( + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language', + tweetRequest +); +twitter.get( + '/:prefix{(dir|dl)}/:handle{[0-9a-zA-Z_]+}/:endpoint{status(es)?}/:id/:mediaType{(photos?|videos?)}/:mediaNumber{[1-4]}/:language/', tweetRequest ); diff --git a/src/realms/twitter/routes/profile.ts b/src/realms/twitter/routes/profile.ts index 9394d85..37535b3 100644 --- a/src/realms/twitter/routes/profile.ts +++ b/src/realms/twitter/routes/profile.ts @@ -50,7 +50,6 @@ export const profileRequest = async (c: Context) => { console.log('Bypass bot check'); } - /* This throws the necessary data to handleStatus (in status.ts) */ const profileResponse = await handleProfile(c, username, flags); /* Check for custom redirect */