Skip to content

Commit

Permalink
fixed incorrect error display when trying a team URL with one charact…
Browse files Browse the repository at this point in the history
  • Loading branch information
fraziern authored and enahum committed Oct 17, 2016
1 parent eac472b commit 06e5c09
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions webapp/components/create_team/components/team_url.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 06e5c09

Please sign in to comment.