mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-09-12 19:51:00 +05:00
fix(dns): apply content normalization in upsert match logic to prevent duplicates
This commit is contained in:
parent
91db4e60c4
commit
df0986b4e1
@ -175,8 +175,16 @@ export const cloudflareClient: DnsClient<CloudflareConfig> = {
|
||||
`/zones/${record.zoneId}/dns_records?type=${record.type}&name=${encodeURIComponent(record.name)}`,
|
||||
);
|
||||
|
||||
const built = buildValue(record);
|
||||
const normalizedRecord = {
|
||||
type: record.type,
|
||||
content: built.content ?? record.content.trim(),
|
||||
priority: built.priority,
|
||||
};
|
||||
const expectedContent = inlinePriority(normalizedRecord);
|
||||
|
||||
const existingRecord = existing.find(
|
||||
(r) => inlinePriority(r) === record.content,
|
||||
(r) => inlinePriority(r) === expectedContent,
|
||||
);
|
||||
if (existingRecord) {
|
||||
const updated = await cfFetch<{ id: string }>(
|
||||
|
||||
@ -172,11 +172,14 @@ export const infomaniakClient: DnsClient<InfomaniakConfig> = {
|
||||
async upsertRecord(config, record) {
|
||||
const source = toSource(record.name, record.zoneId);
|
||||
const existing = await listZoneRecords(config, record.zoneId);
|
||||
const expectedContent = unquoteTarget(
|
||||
quoteTarget(record.type, record.content),
|
||||
);
|
||||
const match = existing.find(
|
||||
(candidate) =>
|
||||
candidate.type === record.type &&
|
||||
normalizeSource(candidate.source) === source &&
|
||||
unquoteTarget(candidate.target) === record.content,
|
||||
unquoteTarget(candidate.target) === expectedContent,
|
||||
);
|
||||
|
||||
const body = JSON.stringify(recordPayload(record, record.zoneId));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user