diff --git a/assets/components/search/DomainSearchBar.tsx b/assets/components/search/DomainSearchBar.tsx index b712fe1..e315783 100644 --- a/assets/components/search/DomainSearchBar.tsx +++ b/assets/components/search/DomainSearchBar.tsx @@ -7,7 +7,7 @@ export type FieldType = { ldhName: string } -export function DomainSearchBar({onFinish}: { onFinish: (values: FieldType) => void }) { +export function DomainSearchBar({onFinish, initialValue}: { onFinish: (values: FieldType) => void, initialValue?: string }) { return
v > name="ldhName" + initialValue={initialValue} rules={[{ required: true, message: t`Required` diff --git a/assets/pages/search/DomainSearchPage.tsx b/assets/pages/search/DomainSearchPage.tsx index c263d18..282f3e7 100644 --- a/assets/pages/search/DomainSearchPage.tsx +++ b/assets/pages/search/DomainSearchPage.tsx @@ -17,24 +17,26 @@ export default function DomainSearchPage() { const onFinish: FormProps['onFinish'] = (values) => { navigate('/search/domain/' + values.ldhName) - } - - useEffect(() => { - if (query === undefined) return setDomain(null) - getDomain(query).then(d => { + getDomain(values.ldhName).then(d => { setDomain(d) messageApi.success(t`Found !`) }).catch((e: AxiosError) => { setDomain(undefined) showErrorAPI(e, messageApi) }) + } + + useEffect(() => { + if (query === undefined) return + + onFinish({ldhName: query}) }, [query]) return {contextHolder} - + { diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 4e09d73..3f86429 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -41,9 +41,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; readonly class RDAPService { - /** - * @see https://www.iana.org/domains/root/db - */ + /* @see https://www.iana.org/domains/root/db */ public const ISO_TLD_EXCEPTION = ['ac', 'eu', 'uk', 'su', 'tp']; public const INFRA_TLD = ['arpa']; public const SPONSORED_TLD = [ @@ -175,9 +173,14 @@ readonly class RDAPService if (false === $lastDotPosition) { throw new BadRequestException('Domain must contain at least one dot'); } - $tld = strtolower(idn_to_ascii(substr($domain, $lastDotPosition + 1))); - return $this->tldRepository->findOneBy(['tld' => $tld]); + $tld = strtolower(idn_to_ascii(substr($domain, $lastDotPosition + 1))); + $tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]); + if (null === $tldEntity) { + throw new NotFoundHttpException("The requested TLD is not yet supported, please try again with another one"); + } + + return $tldEntity; } private function convertToIdn(string $fqdn): string