mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-10 21:10:54 +01:00
Passthrough Twitter moments links
This commit is contained in:
parent
ace4d2af03
commit
f36ae739a5
2 changed files with 17 additions and 0 deletions
|
@ -147,6 +147,11 @@ const profileRequest = async (request: Request) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const genericTwitterRedirect = async (request: Request) => {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
return Response.redirect(`${Constants.TWITTER_ROOT}${url.pathname}`, 302);
|
||||||
|
}
|
||||||
|
|
||||||
const versionRequest = async (request: Request) => {
|
const versionRequest = async (request: Request) => {
|
||||||
return new Response(
|
return new Response(
|
||||||
Strings.VERSION_HTML.format({
|
Strings.VERSION_HTML.format({
|
||||||
|
@ -237,6 +242,7 @@ router.get('/owoembed', async (request: Request) => {
|
||||||
but it's something we might do. Maybe. */
|
but it's something we might do. Maybe. */
|
||||||
router.get('/:handle', profileRequest);
|
router.get('/:handle', profileRequest);
|
||||||
router.get('/:handle/', profileRequest);
|
router.get('/:handle/', profileRequest);
|
||||||
|
router.get('/i/events/:id', genericTwitterRedirect);
|
||||||
|
|
||||||
/* If we don't understand the route structure at all, we'll
|
/* If we don't understand the route structure at all, we'll
|
||||||
redirect to GitHub (normal domains) or API docs (api.fxtwitter.com) */
|
redirect to GitHub (normal domains) or API docs (api.fxtwitter.com) */
|
||||||
|
|
|
@ -37,6 +37,17 @@ test('Tweet redirect human', async () => {
|
||||||
expect(result.headers.get('location')).toEqual('https://twitter.com/jack/status/20');
|
expect(result.headers.get('location')).toEqual('https://twitter.com/jack/status/20');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Twitter moment redirect', async () => {
|
||||||
|
const result = await cacheWrapper(
|
||||||
|
new Request('https://fxtwitter.com/i/events/1572638642127966214?t=0UK7Ny-Jnsp-dUGzlb-M8w&s=35', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: botHeaders
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(result.status).toEqual(302);
|
||||||
|
expect(result.headers.get('location')).toEqual('https://twitter.com/i/events/1572638642127966214');
|
||||||
|
});
|
||||||
|
|
||||||
test('Tweet response robot', async () => {
|
test('Tweet response robot', async () => {
|
||||||
const result = await cacheWrapper(
|
const result = await cacheWrapper(
|
||||||
new Request('https://fxtwitter.com/jack/status/20', {
|
new Request('https://fxtwitter.com/jack/status/20', {
|
||||||
|
|
Loading…
Add table
Reference in a new issue