Changeset View
Changeset View
Standalone View
Standalone View
lib/shared/account-utils.js
Show All 10 Lines | |||||
// usernames used to be less restrictive (eg single chars were allowed) | // usernames used to be less restrictive (eg single chars were allowed) | ||||
// use oldValidUsername when dealing with existing accounts | // use oldValidUsername when dealing with existing accounts | ||||
const oldValidUsernameRegexString = '[a-zA-Z0-9-_]+'; | const oldValidUsernameRegexString = '[a-zA-Z0-9-_]+'; | ||||
const oldValidUsernameRegex: RegExp = new RegExp( | const oldValidUsernameRegex: RegExp = new RegExp( | ||||
`^${oldValidUsernameRegexString}$`, | `^${oldValidUsernameRegexString}$`, | ||||
); | ); | ||||
// when bolding @-mentions, we want to match both valid usernames and also | |||||
// resolved ENS names that have a . character in them (eg. "foo.eth") | |||||
const markdownUserMentionRegexString = '[a-zA-Z0-9-_.]+'; | |||||
const validEmailRegex: RegExp = new RegExp( | const validEmailRegex: RegExp = new RegExp( | ||||
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+/.source + | /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+/.source + | ||||
/@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?/.source + | /@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?/.source + | ||||
/(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.source, | /(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.source, | ||||
); | ); | ||||
const validHexColorRegex: RegExp = /^[a-fA-F0-9]{6}$/; | const validHexColorRegex: RegExp = /^[a-fA-F0-9]{6}$/; | ||||
Show All 21 Lines | ): ?string { | ||||
const ethAddress = | const ethAddress = | ||||
username && userIdentifiedByETHAddress(userInfo) ? username : null; | username && userIdentifiedByETHAddress(userInfo) ? username : null; | ||||
return ethAddress; | return ethAddress; | ||||
} | } | ||||
export { | export { | ||||
usernameMaxLength, | usernameMaxLength, | ||||
oldValidUsernameRegexString, | |||||
validUsernameRegex, | validUsernameRegex, | ||||
oldValidUsernameRegex, | oldValidUsernameRegex, | ||||
markdownUserMentionRegexString, | |||||
validEmailRegex, | validEmailRegex, | ||||
validHexColorRegex, | validHexColorRegex, | ||||
accountHasPassword, | accountHasPassword, | ||||
userIdentifiedByETHAddress, | userIdentifiedByETHAddress, | ||||
getETHAddressForUserInfo, | getETHAddressForUserInfo, | ||||
}; | }; |