mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 08:43:02 +00:00
Merge remote-tracking branch 'Maddy/fix/categoryNames' into staging
This commit is contained in:
2 files changed
+14
-7
No files matched your search
@@ -181,10 +181,16 @@ export class Channel extends BaseClass {
|
||||
for (let character of InvisibleCharacters)
|
||||
if (channel.name.includes(character)) throw new HTTPError("Channel name cannot include invalid characters", 403);
|
||||
|
||||
if (channel.name.match(/\-\-+/g)) throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403);
|
||||
// Categories and voice skip these checks on discord.com
|
||||
const skipChecksTypes = [ChannelType.GUILD_CATEGORY, ChannelType.GUILD_VOICE];
|
||||
if ((channel.type && !skipChecksTypes.includes(channel.type)) || guild.features.includes("IRC_LIKE_CHANNEL_NAMES")) {
|
||||
if (channel.name.includes(" ")) throw new HTTPError("Channel name cannot include invalid characters", 403);
|
||||
|
||||
if (channel.name.charAt(0) === "-" || channel.name.charAt(channel.name.length - 1) === "-")
|
||||
throw new HTTPError("Channel name cannot start/end with dash.", 403);
|
||||
if (channel.name.match(/\-\-+/g)) throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403);
|
||||
|
||||
if (channel.name.charAt(0) === "-" || channel.name.charAt(channel.name.length - 1) === "-")
|
||||
throw new HTTPError("Channel name cannot start/end with dash.", 403);
|
||||
} else channel.name = channel.name.trim(); //category names are trimmed client side on discord.com
|
||||
}
|
||||
|
||||
if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// List from https://invisible-characters.com/
|
||||
export const InvisibleCharacters = [
|
||||
"\u{9}", //Tab
|
||||
"\u{20}", //Space
|
||||
"\u{c}", //Form feed
|
||||
//'\u{20}', //Space //categories can have spaces in them
|
||||
"\u{ad}", //Soft hyphen
|
||||
"\u{34f}", //Combining grapheme joiner
|
||||
// '\u{34f}', //Combining grapheme joiner
|
||||
"\u{61c}", //Arabic letter mark
|
||||
"\u{115f}", //Hangul choseong filler
|
||||
"\u{1160}", //Hangul jungseong filler
|
||||
@@ -23,12 +24,12 @@ export const InvisibleCharacters = [
|
||||
"\u{200a}", //Hair space
|
||||
"\u{200b}", //Zero width space
|
||||
"\u{200c}", //Zero width non-joiner
|
||||
"\u{200d}", //Zero width joiner
|
||||
// '\u{200d}', //Zero width joiner
|
||||
"\u{200e}", //Left-to-right mark
|
||||
"\u{200f}", //Right-to-left mark
|
||||
"\u{202f}", //Narrow no-break space
|
||||
"\u{205f}", //Medium mathematical space
|
||||
"\u{2060}", //Word joiner
|
||||
// '\u{2060}', //Word joiner -- WJ is required in some languages that don't use spaces to split words
|
||||
"\u{2061}", //Function application
|
||||
"\u{2062}", //Invisible times
|
||||
"\u{2063}", //Invisible separator
|
||||
|
||||
Reference in new issue
Block a user