Add tests for routes with trailing slashes (prevent #480 incident again)

This commit is contained in:
dangered wolf 2023-11-10 20:09:47 -05:00
parent d33eb226b1
commit 0e4f17d279
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -58,6 +58,17 @@ test('Tweet redirect human', async () => {
expect(result.headers.get('location')).toEqual('https://twitter.com/jack/status/20');
});
test('Tweet redirect human trailing slash', async () => {
const result = await app.request(
new Request('https://fxtwitter.com/jack/status/20/', {
method: 'GET',
headers: humanHeaders
})
);
expect(result.status).toEqual(302);
expect(result.headers.get('location')).toEqual('https://twitter.com/jack/status/20');
});
test('Tweet redirect human custom base redirect', async () => {
const result = await app.request(
new Request('https://fxtwitter.com/jack/status/20', {
@ -96,6 +107,16 @@ test('Tweet response robot', async () => {
expect(result.status).toEqual(200);
});
test('Tweet response robot (trailing slash/query string)', async () => {
const result = await app.request(
new Request('https://fxtwitter.com/jack/status/20/?asdf=ghjk&klop;', {
method: 'GET',
headers: botHeaders
})
);
expect(result.status).toEqual(200);
});
test('API fetch basic Tweet', async () => {
const result = await app.request(
new Request('https://api.fxtwitter.com/status/20', {