No symbols in fold primary tag. Limit Name to 140 chars
This commit is contained in:
parent
c047365bb4
commit
2e7a8210bb
|
@ -28,10 +28,12 @@ export const createFold = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
if (!name || typeof name !== 'string')
|
if (!name || typeof name !== 'string')
|
||||||
return { status: 'error', message: 'Name must be a non-empty string' }
|
return { status: 'error', message: 'Name must be a non-empty string' }
|
||||||
|
|
||||||
|
name = name.trim().slice(0, 140)
|
||||||
|
|
||||||
if (!about || typeof about !== 'string')
|
if (!about || typeof about !== 'string')
|
||||||
return { status: 'error', message: 'About must be a non-empty string' }
|
return { status: 'error', message: 'About must be a non-empty string' }
|
||||||
|
|
||||||
about = about.slice(0, 140)
|
about = about.trim().slice(0, 140)
|
||||||
|
|
||||||
if (!_.isArray(tags))
|
if (!_.isArray(tags))
|
||||||
return { status: 'error', message: 'Tags must be an array of strings' }
|
return { status: 'error', message: 'Tags must be an array of strings' }
|
||||||
|
|
|
@ -81,6 +81,7 @@ export function CreateFoldButton() {
|
||||||
className="input input-bordered resize-none"
|
className="input input-bordered resize-none"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
value={name}
|
value={name}
|
||||||
|
maxLength={140}
|
||||||
onChange={(e) => updateName(e.target.value || '')}
|
onChange={(e) => updateName(e.target.value || '')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@ export function formatPercent(zeroToOne: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toCamelCase(words: string) {
|
export function toCamelCase(words: string) {
|
||||||
return words
|
const camelCase = words
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map((word) => word.trim())
|
.map((word) => word.trim())
|
||||||
.filter((word) => word)
|
.filter((word) => word)
|
||||||
|
@ -26,4 +26,8 @@ export function toCamelCase(words: string) {
|
||||||
index === 0 ? word : word[0].toLocaleUpperCase() + word.substring(1)
|
index === 0 ? word : word[0].toLocaleUpperCase() + word.substring(1)
|
||||||
)
|
)
|
||||||
.join('')
|
.join('')
|
||||||
|
|
||||||
|
// Remove non-alpha-numeric-underscore chars.
|
||||||
|
const regex = /(?:^|\s)(?:[a-z0-9_]+)/gi
|
||||||
|
return (camelCase.match(regex) || [])[0] ?? ''
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user