mirror of
https://github.com/urbit/shrub.git
synced 2024-11-30 22:15:47 +03:00
chat: validate chat names
Add a regex check for non-lowercase, non-slash, non-hyphen characters, or numerals, and a quick check for starts-with-slashes, double-slashes, to a boolean before creating a chat at that path.
This commit is contained in:
parent
a64e516fc5
commit
e2cfcafc92
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -77,7 +77,15 @@ export class NewScreen extends Component {
|
||||
|
||||
onClickCreate() {
|
||||
const { props, state } = this;
|
||||
if (!state.idName) {
|
||||
|
||||
let invalidChara = new RegExp(/[^a-z0-9/-]/);
|
||||
|
||||
let invalid = (
|
||||
(!state.idName) || (state.idName.startsWith("/")) ||
|
||||
(state.idName.includes("//")) || (invalidChara.test(state.idName))
|
||||
);
|
||||
|
||||
if (invalid) {
|
||||
this.setState({
|
||||
idError: true,
|
||||
inviteError: false
|
||||
@ -192,7 +200,7 @@ export class NewScreen extends Component {
|
||||
<div className="w-100">
|
||||
<p className="f8 mt3 lh-copy db">Chat Name</p>
|
||||
<p className="f9 gray2 db mb4">
|
||||
Alphanumeric characters, dashes, and slashes only
|
||||
Lowercase alphanumeric characters, dashes, and slashes only
|
||||
</p>
|
||||
<textarea
|
||||
className="f7 ba b--gray3 pa3 db w-100"
|
||||
|
Loading…
Reference in New Issue
Block a user