Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix handle length error message (#7802)

authored by

Samuel Newman and committed by
GitHub
798bf478 b0f7f51b

+7 -9
+3 -5
src/lib/strings/handles.ts
··· 5 5 const VALIDATE_REGEX = 6 6 /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/ 7 7 8 + export const MAX_SERVICE_HANDLE_LENGTH = 18 9 + 8 10 export function makeValidHandle(str: string): string { 9 11 if (str.length > 20) { 10 12 str = str.slice(0, 20) ··· 17 19 name = (name || '').replace(/[.]+$/, '') 18 20 domain = (domain || '').replace(/^[.]+/, '') 19 21 return `${name}.${domain}` 20 - } 21 - 22 - export function maxServiceHandleLength(domain: string): number { 23 - return 30 - `.${(domain || '').replace(/^[.]+/, '')}`.length 24 22 } 25 23 26 24 export function isInvalidHandle(handle: string): boolean { ··· 52 50 handleChars: 53 51 !str || (VALIDATE_REGEX.test(fullHandle) && !str.includes('.')), 54 52 hyphenStartOrEnd: !str.startsWith('-') && !str.endsWith('-'), 55 - frontLength: str.length >= 3 && str.length <= 18, 53 + frontLength: str.length >= 3 && str.length <= MAX_SERVICE_HANDLE_LENGTH, 56 54 totalLength: fullHandle.length <= 253, 57 55 } 58 56
+4 -4
src/screens/Signup/StepHandle.tsx
··· 6 6 import {logEvent} from '#/lib/statsig/statsig' 7 7 import { 8 8 createFullHandle, 9 - maxServiceHandleLength, 9 + MAX_SERVICE_HANDLE_LENGTH, 10 10 validateServiceHandle, 11 11 } from '#/lib/strings/handles' 12 12 import {useAgent} from '#/state/session' ··· 168 168 <IsValidIcon 169 169 valid={validCheck.frontLength && validCheck.totalLength} 170 170 /> 171 - {!validCheck.totalLength ? ( 171 + {!validCheck.totalLength || 172 + draftValue.length > MAX_SERVICE_HANDLE_LENGTH ? ( 172 173 <Text style={[a.text_md, a.flex_1]}> 173 174 <Trans> 174 - No longer than {maxServiceHandleLength(state.userDomain)}{' '} 175 - characters 175 + No longer than {MAX_SERVICE_HANDLE_LENGTH} characters 176 176 </Trans> 177 177 </Text> 178 178 ) : (