mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
d60c3242af
swc_bundler: - Fix cycle detection for complex circular imports. (denoland/deno#10752) swc_ecma_transforms_typescript: - Allow using large values for an enum variant.
29 lines
966 B
TypeScript
29 lines
966 B
TypeScript
// Loaded from https://deno.land/x/discordeno@11.0.0-rc.2/src/rest/simplify_url.ts
|
|
|
|
|
|
/**
|
|
* Credits: github.com/abalabahaha/eris lib/rest/RequestHandler.js#L397
|
|
* Modified for our usecase
|
|
*/
|
|
|
|
export function simplifyUrl(url: string, method: string) {
|
|
let route = url
|
|
.replace(/\/([a-z-]+)\/(?:[0-9]{17,19})/g, function (match, p) {
|
|
return ["channels", "guilds", "webhooks"].includes(p) ? match : `/${p}/skillzPrefersID`;
|
|
})
|
|
.replace(/\/reactions\/[^/]+/g, "/reactions/skillzPrefersID")
|
|
.replace(/^\/webhooks\/(\d+)\/[A-Za-z0-9-_]{64,}/, "/webhooks/$1/:itohIsAHoti");
|
|
|
|
// GENERAL /reactions and /reactions/emoji/@me share the buckets
|
|
if (route.includes("/reactions")) {
|
|
route = route.substring(0, route.indexOf("/reactions") + "/reactions".length);
|
|
}
|
|
|
|
// Delete Messsage endpoint has its own ratelimit
|
|
if (method === "DELETE" && route.endsWith("/messages/skillzPrefersID")) {
|
|
route = method + route;
|
|
}
|
|
|
|
return route;
|
|
}
|