Open lastarel opened 2 years ago
Hi @lastarel
Thank you for the PR. Could you please write a test for your scenario so I can review your changes?
Hi,
Not really sure what you refer to by a test as I've commented above pre-post the responses received.
As to not make another commit with a simple test you can run this test :
it('Should query TXT for spf.test.com and return a full valid value for spf', (done) => { dig(['spf.test.com', 'TXT']) .then((result) => { expect(result).to.be.an('object') .and.to.have.property('question') .and.to.be.an('array'); expect(result).to.have.property('answer') .and.to.be.an('array'); expect(result.answer[0].value).to.be.a('string') expect(result).to.have.property('time') .and.to.be.an('number'); expect(result).to.have.property('server') .and.to.be.an('string'); expect(result).to.have.property('datetime') .and.to.be.an('string'); expect(result).to.have.property('size') .and.to.be.an('number'); expect(result.answer[0].value).to.contain('v=spf1 ~all') expect(result.answer[0].type).to.equal("TXT") done(); }) .catch((err) => { console.log('Error:', err); }); });
It's a spin from your MX test so you can check the properties and values as well as the TXT return value.
Good luck hope it helps.
This bugfix uses joins(' ') to re-combine the improperly split TXT record by the previous line.split(/\s+/g). This does not work for a train of consecutive whitespaces inside the TXT record.
Hi,
For TXT records that can have whitespaces such as: SPF records: IE: "v=spf1 include:_spf.google.com ~all" Prior to commit this would've been parsed as: dig(['google.com','TXT']).then((res)=>{ console.log(res.answer) })
{ domain: 'google.com.', type: 'TXT', ttl: '3591', class: 'IN', value: '~all"' },
Post commit: dig(['google.com','TXT']).then((res)=>{ console.log(res.answer) })
{ domain: 'google.com.', type: 'TXT', ttl: '3561', class: 'IN', value: '"v=spf1 include:_spf.google.com ~all"' },