mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-21 10:50:08 +00:00
fix: route escaping round three
This commit is contained in:
@@ -40,7 +40,8 @@ export type DistributiveOmit<T, K extends DistributiveKeys<T>> =
|
||||
|
||||
type Omit_<T, K> = Omit<T, Extract<keyof T, K>>;
|
||||
|
||||
const pattern = /^[\d%A-Za-z-]+$/g;
|
||||
// eslint-disable-next-line unicorn/better-regex
|
||||
const pattern = /^[\d%A-Za-z-_]+$/g;
|
||||
|
||||
export const urlSafeCharacters = {
|
||||
test(input: string) {
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
import { strictEqual } from 'node:assert';
|
||||
import { Routes } from '../../v10';
|
||||
|
||||
const expected = '/channels/1320466398597615666/messages/1320622300642545705/reactions/%F0%9F%95%99/@me';
|
||||
const channelId = '1320466398597615666';
|
||||
const messageId = '1320622300642545705';
|
||||
|
||||
strictEqual(Routes.channelMessageOwnReaction('1320466398597615666', '1320622300642545705', '%F0%9F%95%99'), expected);
|
||||
strictEqual(Routes.channelMessageOwnReaction('1320466398597615666', '1320622300642545705', '%F0%9F%95%99'), expected);
|
||||
strictEqual(Routes.channelMessageOwnReaction('1320466398597615666', '1320622300642545705', '%F0%9F%95%99'), expected);
|
||||
const expected = `/channels/${channelId}/messages/${messageId}/reactions/%F0%9F%95%99/@me`;
|
||||
|
||||
// Run multiple times to ensure that the validation isn't intermittent
|
||||
strictEqual(Routes.channelMessageOwnReaction(channelId, messageId, '%F0%9F%95%99'), expected);
|
||||
strictEqual(Routes.channelMessageOwnReaction(channelId, messageId, '%F0%9F%95%99'), expected);
|
||||
strictEqual(Routes.channelMessageOwnReaction(channelId, messageId, '%F0%9F%95%99'), expected);
|
||||
|
||||
// make sure that the emoji is properly encoded
|
||||
const emoji = '🕙';
|
||||
|
||||
strictEqual(Routes.channelMessageOwnReaction('1320466398597615666', '1320622300642545705', emoji), expected);
|
||||
strictEqual(Routes.channelMessageOwnReaction(channelId, messageId, emoji), expected);
|
||||
|
||||
// test custom emojis too
|
||||
const animated = '1_:1234567890';
|
||||
const encodedExpected = '1_%3A1234567890';
|
||||
|
||||
const expected2 = `/channels/${channelId}/messages/${messageId}/reactions/${encodedExpected}/@me`;
|
||||
|
||||
strictEqual(Routes.channelMessageOwnReaction(channelId, messageId, animated), expected2);
|
||||
strictEqual(Routes.channelMessageOwnReaction(channelId, messageId, encodedExpected), expected2);
|
||||
|
||||
@@ -40,7 +40,8 @@ export type DistributiveOmit<T, K extends DistributiveKeys<T>> =
|
||||
|
||||
type Omit_<T, K> = Omit<T, Extract<keyof T, K>>;
|
||||
|
||||
const pattern = /^[\d%A-Za-z-]+$/g;
|
||||
// eslint-disable-next-line unicorn/better-regex
|
||||
const pattern = /^[\d%A-Za-z-_]+$/g;
|
||||
|
||||
export const urlSafeCharacters = {
|
||||
test(input: string) {
|
||||
|
||||
Reference in New Issue
Block a user