Merge pull request #2230 from urbit/contacts-group-validate

Validate group names
This commit is contained in:
Logan 2020-02-06 11:25:11 -08:00 committed by GitHub
commit 757354db16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -69,11 +69,10 @@ export class NewScreen extends Component {
onClickCreate() {
const { props, state } = this;
let invalidChara = new RegExp(/[^a-z0-9/-]/);
let validChar = /^[a-z0-9~_.-]*$/;
let invalid = (
(!state.idName) || (state.idName.startsWith("/")) ||
(state.idName.includes("//")) || (invalidChara.test(state.idName))
(!state.idName) || (!validChara.test(state.idName))
);
if (invalid) {

View File

@ -34,13 +34,19 @@ export class NewScreen extends Component {
onClickCreate() {
const { props, state } = this;
if (!state.groupName) {
let validChar = /^[a-z0-9~_.-]*$/;
if (
(!state.groupName) || (!validChar.test(state.groupName))
) {
this.setState({
groupNameError: true,
inviteError: false
});
return;
}
let group = `/~${window.ship}` + `/${state.groupName}`;
let aud = [];
@ -56,7 +62,7 @@ export class NewScreen extends Component {
}
});
}
if (!isValid) {
this.setState({
inviteError: true,