mirror of
https://github.com/discordjs/discord-api-types.git
synced 2026-05-30 07:20:10 +00:00
fix: reset pattern index after testing an input
Otherwise, we flip flop between validations See https://github.com/discordjs/discord-api-types/issues/1181#issuecomment-2558971449
This commit is contained in:
@@ -40,4 +40,14 @@ export type DistributiveOmit<T, K extends DistributiveKeys<T>> =
|
||||
|
||||
type Omit_<T, K> = Omit<T, Extract<keyof T, K>>;
|
||||
|
||||
export const urlSafeCharacters = /^[\d%A-Za-z-]+$/g;
|
||||
const pattern = /^[\d%A-Za-z-]+$/g;
|
||||
|
||||
export const urlSafeCharacters = {
|
||||
test(input: string) {
|
||||
const result = pattern.test(input);
|
||||
|
||||
pattern.lastIndex = 0;
|
||||
|
||||
return result;
|
||||
},
|
||||
};
|
||||
|
||||
12
tests/v10/routes-escaping.ts
Normal file
12
tests/v10/routes-escaping.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { strictEqual } from 'node:assert';
|
||||
import { Routes } from '../../v10';
|
||||
|
||||
const expected = '/channels/1320466398597615666/messages/1320622300642545705/reactions/%F0%9F%95%99/@me';
|
||||
|
||||
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 emoji = '🕙';
|
||||
|
||||
strictEqual(Routes.channelMessageOwnReaction('1320466398597615666', '1320622300642545705', emoji), expected);
|
||||
@@ -40,4 +40,14 @@ export type DistributiveOmit<T, K extends DistributiveKeys<T>> =
|
||||
|
||||
type Omit_<T, K> = Omit<T, Extract<keyof T, K>>;
|
||||
|
||||
export const urlSafeCharacters = /^[\d%A-Za-z-]+$/g;
|
||||
const pattern = /^[\d%A-Za-z-]+$/g;
|
||||
|
||||
export const urlSafeCharacters = {
|
||||
test(input: string) {
|
||||
const result = pattern.test(input);
|
||||
|
||||
pattern.lastIndex = 0;
|
||||
|
||||
return result;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user