mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-10 13:00:53 +01:00
✨ Added language path param and fixed lint
Disabled test.only
This commit is contained in:
parent
68f77c98cd
commit
14e0ab7a61
2 changed files with 65 additions and 66 deletions
|
@ -165,11 +165,12 @@ const profileRequest = async (request: IRequest, event: FetchEvent,
|
|||
if (handle.match(/\w{1,15}/gi)?.[0] !== handle) {
|
||||
return Response.redirect(Constants.REDIRECT_URL, 302);
|
||||
}
|
||||
const username = handle.match(/\w{1,15}/gi)?.[0];
|
||||
const username = handle.match(/\w{1,15}/gi)?.[0] as string;
|
||||
/* Check if request is to api.fxtwitter.com, or the tweet is appended with .json
|
||||
Note that unlike TwitFix, FixTweet will never generate embeds for .json, and
|
||||
in fact we only support .json because it's what people using TwitFix API would
|
||||
be used to. */
|
||||
be used to.
|
||||
*/
|
||||
if (
|
||||
url.pathname.match(/\/status(es)?\/\d{2,20}\.(json)/g) !== null ||
|
||||
Constants.API_HOST_LIST.includes(url.hostname)
|
||||
|
@ -188,7 +189,7 @@ const profileRequest = async (request: IRequest, event: FetchEvent,
|
|||
|
||||
/* This throws the necessary data to handleStatus (in status.ts) */
|
||||
const profileResponse = await handleProfile(
|
||||
handle.match(/\w{1,15}/gi)?.[0] || '',
|
||||
username,
|
||||
userAgent,
|
||||
flags,
|
||||
language,
|
||||
|
@ -233,8 +234,6 @@ const profileRequest = async (request: IRequest, event: FetchEvent,
|
|||
302
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
const genericTwitterRedirect = async (request: IRequest) => {
|
||||
|
@ -337,7 +336,7 @@ router.get('/owoembed', async (request: IRequest) => {
|
|||
We don't currently have custom profile cards yet,
|
||||
but it's something we might do. Maybe. */
|
||||
router.get('/:handle', profileRequest);
|
||||
router.get('/:handle/', profileRequest);
|
||||
router.get('/:handle/:language', profileRequest);
|
||||
router.get('/i/events/:id', genericTwitterRedirect);
|
||||
router.get('/hashtag/:hashtag', genericTwitterRedirect);
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ test('API fetch poll Tweet', async () => {
|
|||
expect(choices[3].percentage).toEqual(58);
|
||||
});
|
||||
|
||||
test.only('API fetch user', async () => {
|
||||
test('API fetch user', async () => {
|
||||
const result = await cacheWrapper(
|
||||
new Request('https://api.fxtwitter.com/wazbat', {
|
||||
method: 'GET',
|
||||
|
|
Loading…
Add table
Reference in a new issue