diff options
Diffstat (limited to 'webapp/components')
-rw-r--r-- | webapp/components/create_team/components/team_url.jsx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/webapp/components/create_team/components/team_url.jsx b/webapp/components/create_team/components/team_url.jsx index b6c7d38f3..d2ccc97d9 100644 --- a/webapp/components/create_team/components/team_url.jsx +++ b/webapp/components/create_team/components/team_url.jsx @@ -36,20 +36,22 @@ export default class TeamUrl extends React.Component { e.preventDefault(); const name = ReactDOM.findDOMNode(this.refs.name).value.trim(); + const cleanedName = Utils.cleanUpUrlable(name); + const urlRegex = /^[a-z]+([a-z\-0-9]+|(__)?)[a-z0-9]+$/g; + if (!name) { this.setState({nameError: Utils.localizeMessage('create_team.team_url.required', 'This field is required')}); return; } - const cleanedName = Utils.cleanUpUrlable(name); + if (cleanedName.length < Constants.MIN_TEAMNAME_LENGTH || cleanedName.length > Constants.MAX_TEAMNAME_LENGTH) { + this.setState({nameError: Utils.localizeMessage('create_team.team_url.charLength', 'Name must be 4 or more characters up to a maximum of 15')}); + return; + } - const urlRegex = /^[a-z]+([a-z\-0-9]+|(__)?)[a-z0-9]+$/g; if (cleanedName !== name || !urlRegex.test(name)) { this.setState({nameError: Utils.localizeMessage('create_team.team_url.regex', "Use only lower case letters, numbers and dashes. Must start with a letter and can't end in a dash.")}); return; - } else if (cleanedName.length < Constants.MIN_TEAMNAME_LENGTH || cleanedName.length > Constants.MAX_TEAMNAME_LENGTH) { - this.setState({nameError: Utils.localizeMessage('create_team.team_url.charLength', 'Name must be 4 or more characters up to a maximum of 15')}); - return; } if (global.window.mm_config.RestrictTeamNames === 'true') { |