only check reserved handles for bsky.social, fix test
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {IsValidHandle, validateServiceHandle} from '#/lib/strings/handles'
|
import {type IsValidHandle, validateServiceHandle} from '#/lib/strings/handles'
|
||||||
|
|
||||||
describe('handle validation', () => {
|
describe('handle validation', () => {
|
||||||
const valid = [
|
const valid = [
|
||||||
@@ -18,17 +18,17 @@ describe('handle validation', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const invalid = [
|
const invalid = [
|
||||||
['al', 'bsky.social', 'frontLength'],
|
['al', 'bsky.social', 'frontLengthLongEnough'],
|
||||||
['-alice', 'bsky.social', 'hyphenStartOrEnd'],
|
['-alice', 'bsky.social', 'hyphenStartOrEnd'],
|
||||||
['alice-', 'bsky.social', 'hyphenStartOrEnd'],
|
['alice-', 'bsky.social', 'hyphenStartOrEnd'],
|
||||||
['%%%', 'bsky.social', 'handleChars'],
|
['%%%', 'bsky.social', 'handleChars'],
|
||||||
['1234567890123456789', 'bsky.social', 'frontLength'],
|
['1234567890123456789', 'bsky.social', 'frontLengthNotTooLong'],
|
||||||
[
|
[
|
||||||
'1234567890123456789',
|
'1234567890123456789',
|
||||||
'my-custom-pds-with-long-name.social',
|
'my-custom-pds-with-long-name.social',
|
||||||
'frontLength',
|
'frontLengthNotTooLong',
|
||||||
],
|
],
|
||||||
['al', 'my-custom-pds-with-long-name.social', 'frontLength'],
|
['al', 'my-custom-pds-with-long-name.social', 'frontLengthLongEnough'],
|
||||||
['a'.repeat(300), 'toolong.com', 'totalLength'],
|
['a'.repeat(300), 'toolong.com', 'totalLength'],
|
||||||
] satisfies [string, string, keyof IsValidHandle][]
|
] satisfies [string, string, keyof IsValidHandle][]
|
||||||
it.each(invalid)(
|
it.each(invalid)(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const LOCAL_DEV_SERVICE =
|
|||||||
Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583'
|
Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583'
|
||||||
export const STAGING_SERVICE = 'https://staging.bsky.dev'
|
export const STAGING_SERVICE = 'https://staging.bsky.dev'
|
||||||
export const BSKY_SERVICE = 'https://bsky.social'
|
export const BSKY_SERVICE = 'https://bsky.social'
|
||||||
|
export const BSKY_SERVICE_HANDLE_ENDSWITH = '.bsky.social'
|
||||||
export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app'
|
export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app'
|
||||||
export const DEFAULT_SERVICE = BSKY_SERVICE
|
export const DEFAULT_SERVICE = BSKY_SERVICE
|
||||||
const HELP_DESK_LANG = 'en-us'
|
const HELP_DESK_LANG = 'en-us'
|
||||||
@@ -31,7 +32,7 @@ export const DISCOVER_DEBUG_DIDS: Record<string, true> = {
|
|||||||
'did:plc:3jpt2mvvsumj2r7eqk4gzzjz': true, // esb.lol
|
'did:plc:3jpt2mvvsumj2r7eqk4gzzjz': true, // esb.lol
|
||||||
'did:plc:vjug55kidv6sye7ykr5faxxn': true, // emilyliu.me
|
'did:plc:vjug55kidv6sye7ykr5faxxn': true, // emilyliu.me
|
||||||
'did:plc:tgqseeot47ymot4zro244fj3': true, // iwsmith.bsky.social
|
'did:plc:tgqseeot47ymot4zro244fj3': true, // iwsmith.bsky.social
|
||||||
'did:plc:2dzyut5lxna5ljiaasgeuffz': true, // mrnuma.bsky.social
|
'did:plc:2dzyut5lxna5ljiaasgeuffz': true, // darrin.bsky.team
|
||||||
}
|
}
|
||||||
|
|
||||||
const BASE_FEEDBACK_FORM_URL = `${HELP_DESK_URL}/requests/new`
|
const BASE_FEEDBACK_FORM_URL = `${HELP_DESK_URL}/requests/new`
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Animated, {
|
|||||||
import {msg, Plural, Trans} from '@lingui/macro'
|
import {msg, Plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {BSKY_SERVICE_HANDLE_ENDSWITH} from '#/lib/constants'
|
||||||
import {
|
import {
|
||||||
createFullHandle,
|
createFullHandle,
|
||||||
isHandleReserved,
|
isHandleReserved,
|
||||||
@@ -60,7 +61,10 @@ export function StepHandle() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHandleReserved(handle)) {
|
if (
|
||||||
|
state.userDomain === BSKY_SERVICE_HANDLE_ENDSWITH &&
|
||||||
|
isHandleReserved(handle)
|
||||||
|
) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'setError',
|
type: 'setError',
|
||||||
value: _(msg`That username is not available`),
|
value: _(msg`That username is not available`),
|
||||||
@@ -147,7 +151,7 @@ export function StepHandle() {
|
|||||||
// replace em dash with double hyphen to fix iOS behaviour
|
// replace em dash with double hyphen to fix iOS behaviour
|
||||||
setDraftValue(val.replaceAll('—', '--'))
|
setDraftValue(val.replaceAll('—', '--'))
|
||||||
}}
|
}}
|
||||||
label="alice.bsky.social"
|
label={`alice${state.userDomain}`}
|
||||||
defaultValue={draftValue}
|
defaultValue={draftValue}
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {useQuery} from '@tanstack/react-query'
|
import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
import {BSKY_SERVICE_HANDLE_ENDSWITH} from '#/lib/constants'
|
||||||
import {createFullHandle, isHandleReserved} from '#/lib/strings/handles'
|
import {createFullHandle, isHandleReserved} from '#/lib/strings/handles'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
@@ -26,7 +27,10 @@ export function useHandleAvailabilityQuery(
|
|||||||
queryKey: RQKEY_handleAvailability(debouncedHandle),
|
queryKey: RQKEY_handleAvailability(debouncedHandle),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const frontSegment = debouncedHandle.split('.')[0]
|
const frontSegment = debouncedHandle.split('.')[0]
|
||||||
if (isHandleReserved(frontSegment)) {
|
if (
|
||||||
|
domain === BSKY_SERVICE_HANDLE_ENDSWITH &&
|
||||||
|
isHandleReserved(frontSegment)
|
||||||
|
) {
|
||||||
logger.metric(
|
logger.metric(
|
||||||
'signup:handleReserved',
|
'signup:handleReserved',
|
||||||
{typeahead: true},
|
{typeahead: true},
|
||||||
|
|||||||
Reference in New Issue
Block a user