mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-07 07:30:23 +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() {
|
onClickCreate() {
|
||||||
const { props, state } = this;
|
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({
|
this.setState({
|
||||||
idError: true,
|
idError: true,
|
||||||
inviteError: false
|
inviteError: false
|
||||||
@ -192,7 +200,7 @@ export class NewScreen extends Component {
|
|||||||
<div className="w-100">
|
<div className="w-100">
|
||||||
<p className="f8 mt3 lh-copy db">Chat Name</p>
|
<p className="f8 mt3 lh-copy db">Chat Name</p>
|
||||||
<p className="f9 gray2 db mb4">
|
<p className="f9 gray2 db mb4">
|
||||||
Alphanumeric characters, dashes, and slashes only
|
Lowercase alphanumeric characters, dashes, and slashes only
|
||||||
</p>
|
</p>
|
||||||
<textarea
|
<textarea
|
||||||
className="f7 ba b--gray3 pa3 db w-100"
|
className="f7 ba b--gray3 pa3 db w-100"
|
||||||
|
Loading…
Reference in New Issue
Block a user