mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: the field is pre-filled with the requested domain name
This commit is contained in:
@@ -7,7 +7,7 @@ export type FieldType = {
|
|||||||
ldhName: string
|
ldhName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DomainSearchBar({onFinish}: { onFinish: (values: FieldType) => void }) {
|
export function DomainSearchBar({onFinish, initialValue}: { onFinish: (values: FieldType) => void, initialValue?: string }) {
|
||||||
return <Form
|
return <Form
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
@@ -15,6 +15,7 @@ export function DomainSearchBar({onFinish}: { onFinish: (values: FieldType) => v
|
|||||||
>
|
>
|
||||||
<Form.Item<FieldType>
|
<Form.Item<FieldType>
|
||||||
name="ldhName"
|
name="ldhName"
|
||||||
|
initialValue={initialValue}
|
||||||
rules={[{
|
rules={[{
|
||||||
required: true,
|
required: true,
|
||||||
message: t`Required`
|
message: t`Required`
|
||||||
|
|||||||
@@ -17,24 +17,26 @@ export default function DomainSearchPage() {
|
|||||||
|
|
||||||
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
||||||
navigate('/search/domain/' + values.ldhName)
|
navigate('/search/domain/' + values.ldhName)
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (query === undefined) return
|
|
||||||
|
|
||||||
setDomain(null)
|
setDomain(null)
|
||||||
getDomain(query).then(d => {
|
getDomain(values.ldhName).then(d => {
|
||||||
setDomain(d)
|
setDomain(d)
|
||||||
messageApi.success(t`Found !`)
|
messageApi.success(t`Found !`)
|
||||||
}).catch((e: AxiosError) => {
|
}).catch((e: AxiosError) => {
|
||||||
setDomain(undefined)
|
setDomain(undefined)
|
||||||
showErrorAPI(e, messageApi)
|
showErrorAPI(e, messageApi)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (query === undefined) return
|
||||||
|
|
||||||
|
onFinish({ldhName: query})
|
||||||
}, [query])
|
}, [query])
|
||||||
|
|
||||||
return <Flex gap="middle" align="center" justify="center" vertical>
|
return <Flex gap="middle" align="center" justify="center" vertical>
|
||||||
{contextHolder}
|
{contextHolder}
|
||||||
<DomainSearchBar onFinish={onFinish}/>
|
<DomainSearchBar initialValue={query} onFinish={onFinish}/>
|
||||||
|
|
||||||
<Skeleton loading={domain === null} active>
|
<Skeleton loading={domain === null} active>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|||||||
|
|
||||||
readonly class RDAPService
|
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 ISO_TLD_EXCEPTION = ['ac', 'eu', 'uk', 'su', 'tp'];
|
||||||
public const INFRA_TLD = ['arpa'];
|
public const INFRA_TLD = ['arpa'];
|
||||||
public const SPONSORED_TLD = [
|
public const SPONSORED_TLD = [
|
||||||
@@ -175,9 +173,14 @@ readonly class RDAPService
|
|||||||
if (false === $lastDotPosition) {
|
if (false === $lastDotPosition) {
|
||||||
throw new BadRequestException('Domain must contain at least one dot');
|
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
|
private function convertToIdn(string $fqdn): string
|
||||||
|
|||||||
Reference in New Issue
Block a user