mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-18 02:43:46 +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) {
|
if (handle.match(/\w{1,15}/gi)?.[0] !== handle) {
|
||||||
return Response.redirect(Constants.REDIRECT_URL, 302);
|
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
|
/* 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
|
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
|
in fact we only support .json because it's what people using TwitFix API would
|
||||||
be used to. */
|
be used to.
|
||||||
|
*/
|
||||||
if (
|
if (
|
||||||
url.pathname.match(/\/status(es)?\/\d{2,20}\.(json)/g) !== null ||
|
url.pathname.match(/\/status(es)?\/\d{2,20}\.(json)/g) !== null ||
|
||||||
Constants.API_HOST_LIST.includes(url.hostname)
|
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) */
|
/* This throws the necessary data to handleStatus (in status.ts) */
|
||||||
const profileResponse = await handleProfile(
|
const profileResponse = await handleProfile(
|
||||||
handle.match(/\w{1,15}/gi)?.[0] || '',
|
username,
|
||||||
userAgent,
|
userAgent,
|
||||||
flags,
|
flags,
|
||||||
language,
|
language,
|
||||||
|
@ -233,8 +234,6 @@ const profileRequest = async (request: IRequest, event: FetchEvent,
|
||||||
302
|
302
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const genericTwitterRedirect = async (request: IRequest) => {
|
const genericTwitterRedirect = async (request: IRequest) => {
|
||||||
|
@ -337,7 +336,7 @@ router.get('/owoembed', async (request: IRequest) => {
|
||||||
We don't currently have custom profile cards yet,
|
We don't currently have custom profile cards yet,
|
||||||
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/:language', profileRequest);
|
||||||
router.get('/i/events/:id', genericTwitterRedirect);
|
router.get('/i/events/:id', genericTwitterRedirect);
|
||||||
router.get('/hashtag/:hashtag', genericTwitterRedirect);
|
router.get('/hashtag/:hashtag', genericTwitterRedirect);
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ test('API fetch poll Tweet', async () => {
|
||||||
expect(choices[3].percentage).toEqual(58);
|
expect(choices[3].percentage).toEqual(58);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.only('API fetch user', async () => {
|
test('API fetch user', async () => {
|
||||||
const result = await cacheWrapper(
|
const result = await cacheWrapper(
|
||||||
new Request('https://api.fxtwitter.com/wazbat', {
|
new Request('https://api.fxtwitter.com/wazbat', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|
Loading…
Add table
Reference in a new issue