diff --git a/src/components/rooms.js b/src/components/rooms.js index 57c113e..1e84958 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -76,6 +76,8 @@ const validateAlias = fieldval => { } const removeLeadingWhitespace = fieldVal => fieldVal === undefined ? undefined : fieldVal.trimStart(); +const replaceAllWhitespace = fieldVal => fieldVal === undefined ? undefined : fieldVal.replace(/\s/, "_"); +const removeLeadingSigil = fieldVal => fieldVal === undefined ? undefined : fieldVal.startsWith("#") ? fieldVal.substr(1) : fieldVal; const validateHasAliasIfPublic = formdata => { let errors = {}; @@ -94,7 +96,8 @@ export const RoomCreate = props => ( parse={removeLeadingWhitespace} validate={validateDisplayName}/> replaceAllWhitespace(removeLeadingSigil(fv)) } + format={fv => fv === "" ? "" : "#" + fv} validate={validateAlias}/>