From 4072ae056517c443a1ca01b1453aed7f0b12a5ab Mon Sep 17 00:00:00 2001 From: Aneem Date: Tue, 11 Jun 2019 19:10:05 +0545 Subject: [PATCH] fix REMOVE function bug --- lib/index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index bb051a8..8d45741 100644 --- a/lib/index.js +++ b/lib/index.js @@ -114,20 +114,19 @@ module.exports.create = function(config) { }, remove: function(data) { var ch = data.challenge; - var zone = ch.identifier.value; - var dnsPrefix = ch.dnsHost.replace(new RegExp('.' + zone + '$'), ''); - var txt = ch.dnsAuthorization; - var url = baseUrl + '/v2/domains/' + zone + '/records'; - + var domainRecord = ch.identifier.value; + // Digital ocean provides the api to remove records by ID. So we first get the recordId and use it to remove the domain record return helpers.getDomain(domainRecord).then(function(zone) { var dnsPrefix = ch.dnsHost.replace(new RegExp('.' + zone + '$'), ''); + console.info('Removing TXT', data); var payload = { dnsPrefix: dnsPrefix, zone: zone, - txt: data.dnsAuthorization + txt: ch.dnsAuthorization }; + return helpers.getTXTRecord(payload).then(function(txtRecord) { if (txtRecord) { var url =