File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,18 @@ const flexibleUrl = z.preprocess(
2626 value => {
2727 // Check for Twitter (X) handles: @username (alphanumeric, underscore, 1-15 chars)
2828 const twitterHandlePattern = / ^ @ ( [ a - z A - Z 0 - 9 _ ] { 1 , 15 } ) $ /
29- // Check for Discord handles: discord:username#discriminator (e.g., username#1234)
30- const discordHandlePattern = / ^ d i s c o r d : [ a - z A - Z 0 - 9 _ ] + # [ 0 - 9 ] { 4 } $ /
29+ // Check for Discord handles (both old and new style)
30+ const oldDiscordHandlePattern = / ^ d i s c o r d : [ a - z A - Z 0 - 9 _ ] + # [ 0 - 9 ] { 4 } $ /
31+ const newDiscordHandlePattern = / ^ d i s c o r d : [ a - z 0 - 9 ] [ a - z 0 - 9 _ . ] { 0 , 30 } [ a - z 0 - 9 ] $ /
3132 // Check for URLs: protocol, domain, and plausible TLD
3233 const urlPattern = / ^ h t t p s ? : \/ \/ ( [ a - z A - Z 0 - 9 - ] + \. ) * [ a - z A - Z 0 - 9 - ] + \. [ a - z A - Z ] { 2 , } ( \/ .* ) ? $ /
3334
34- return twitterHandlePattern . test ( value ) || discordHandlePattern . test ( value ) || urlPattern . test ( value )
35+ return (
36+ twitterHandlePattern . test ( value ) ||
37+ oldDiscordHandlePattern . test ( value ) ||
38+ newDiscordHandlePattern . test ( value ) ||
39+ urlPattern . test ( value )
40+ )
3541 } ,
3642 {
3743 message :
You can’t perform that action at this time.
0 commit comments