fix: Namecheap API 날짜 형식 변환 (MM/DD/YYYY → ISO)
- Namecheap API가 미국 형식(08/01/2026)을 반환하여 AI가 1월 8일로 오해석 - ISO 형식(2026-08-01)으로 변환하여 명확한 날짜 표시 - list_domains, get_domain_info에 날짜 변환 적용 - 문서에 WHOIS API 서버 정보 및 ccSLD 미지원 안내 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -181,23 +181,44 @@ async function callNamecheapApi(funcName: string, funcArgs: Record<string, any>,
|
||||
const result = await fetch(`${apiUrl}/domains?page=${funcArgs.page || 1}&page_size=${funcArgs.page_size || 100}`, {
|
||||
headers: { 'X-API-Key': apiKey },
|
||||
}).then(r => r.json()) as any[];
|
||||
// 허용된 도메인만 필터링
|
||||
return result.filter((d: any) => allowedDomains.includes(d.name));
|
||||
// MM/DD/YYYY → YYYY-MM-DD 변환 (Namecheap은 미국 형식 사용)
|
||||
const convertDate = (date: string) => {
|
||||
const [month, day, year] = date.split('/');
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
||||
};
|
||||
// 허용된 도메인만 필터링, 날짜는 ISO 형식으로 변환
|
||||
return result
|
||||
.filter((d: any) => allowedDomains.includes(d.name))
|
||||
.map((d: any) => ({
|
||||
...d,
|
||||
created: convertDate(d.created),
|
||||
expires: convertDate(d.expires),
|
||||
user: undefined, // 민감 정보 제거
|
||||
}));
|
||||
}
|
||||
case 'get_domain_info': {
|
||||
const domainInfo = await fetch(`${apiUrl}/domains/${funcArgs.domain}`, {
|
||||
// 목록 API에서 더 많은 정보 조회 (단일 API는 정보 부족)
|
||||
const domains = await fetch(`${apiUrl}/domains?page=1&page_size=100`, {
|
||||
headers: { 'X-API-Key': apiKey },
|
||||
}).then(r => r.json()) as any;
|
||||
// 민감 정보 필터링 (계정 ID 등)
|
||||
}).then(r => r.json()) as any[];
|
||||
const domainInfo = domains.find((d: any) => d.name === funcArgs.domain);
|
||||
if (!domainInfo) {
|
||||
return { error: `도메인을 찾을 수 없습니다: ${funcArgs.domain}` };
|
||||
}
|
||||
// MM/DD/YYYY → YYYY-MM-DD 변환 (Namecheap은 미국 형식 사용)
|
||||
const convertDate = (date: string) => {
|
||||
const [month, day, year] = date.split('/');
|
||||
return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
|
||||
};
|
||||
// 민감 정보 필터링 (user/owner 제거), 날짜는 ISO 형식으로 변환
|
||||
return {
|
||||
domain: domainInfo.name || funcArgs.domain,
|
||||
status: domainInfo.status,
|
||||
created: domainInfo.created,
|
||||
expires: domainInfo.expires,
|
||||
domain: domainInfo.name,
|
||||
created: convertDate(domainInfo.created),
|
||||
expires: convertDate(domainInfo.expires),
|
||||
is_expired: domainInfo.is_expired,
|
||||
auto_renew: domainInfo.auto_renew,
|
||||
is_locked: domainInfo.is_locked,
|
||||
is_premium: domainInfo.is_premium,
|
||||
nameservers: domainInfo.nameservers,
|
||||
whois_guard: domainInfo.whois_guard,
|
||||
};
|
||||
}
|
||||
case 'get_nameservers':
|
||||
@@ -290,6 +311,17 @@ async function callNamecheapApi(funcName: string, funcArgs: Record<string, any>,
|
||||
return { error: `WHOIS 조회 오류: ${whois.error}` };
|
||||
}
|
||||
|
||||
// ccSLD WHOIS 미지원 처리
|
||||
if (whois.whois_supported === false) {
|
||||
return {
|
||||
domain: whois.domain,
|
||||
whois_supported: false,
|
||||
ccSLD: whois.ccSLD,
|
||||
message: whois.message_ko,
|
||||
suggestion: whois.suggestion_ko,
|
||||
};
|
||||
}
|
||||
|
||||
// raw WHOIS 응답을 그대로 반환 (AI가 파싱)
|
||||
return {
|
||||
domain: whois.domain,
|
||||
|
||||
Reference in New Issue
Block a user