Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 10f57ba

Browse files
authored
fix(Bucket): group all invite routes into one bucket (#102)
1 parent 98cada0 commit 10f57ba

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

libs/rest/src/struct/Bucket.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class Bucket {
2626
public static makeRoute(method: string, url: string) {
2727
let route = url
2828
.replace(/\/([a-z-]+)\/(?:[0-9]{17,19})/g, (match, p) => (['channels', 'guilds', 'webhook'].includes(p) ? match : `/${p}/:id`))
29+
.replace(/\/invites\/[\w\d-]{2,}/g, '/invites/:code')
2930
.replace(/\/reactions\/[^/]+/g, '/reactions/:id')
3031
.replace(/^\/webhooks\/(\d+)\/[A-Za-z0-9-_]{64,}/, '/webhooks/$1/:token')
3132
.replace(/\?.*$/, '');

libs/rest/src/struct/rest.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ describe('buckets and rate limiting', () => {
4949

5050
const first = Bucket.makeRoute('delete', '/channels/12345678910111213/messages/12345678910111213');
5151
expect(first).toBe('delete/channels/12345678910111213/messages/:id');
52+
53+
const invite = Bucket.makeRoute('get', '/invites/abcdefgh');
54+
expect(invite).toBe('/invites/:code');
5255
});
5356

5457
describe('make request', () => {

0 commit comments

Comments
 (0)