Skip to content

Commit

Permalink
lib/werist: fix if the whois server response a empty body
Browse files Browse the repository at this point in the history
  • Loading branch information
w4andy committed Nov 13, 2017
1 parent 747b2c5 commit 401fcc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/werist.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,20 @@ class Werist {
buffer = Buffer.concat(chunks);
}

const charsetMatch = detectCharacterEncoding(buffer);
let charsetMatch = null;
if (buffer) {
charsetMatch = detectCharacterEncoding(buffer);
}

if (charsetMatch && charsetMatch.encoding !== 'UTF-8') {
const iconv = new Iconv(charsetMatch.encoding, 'utf-8');
buffer = iconv.convert(buffer);
}

const data = buffer.toString();
let data = '';
if (buffer) {
data = buffer.toString();
}
const _addWhoIsData = (firstData) => {
if (firstData === true) {
if (ctx.options.verbose === true) {
Expand Down
10 changes: 10 additions & 0 deletions test/domain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,14 @@ suite('domain', function() {
done();
});
});

test('altfyrieitt.fo - no response from server', (done) => {
werist.lookup('altfyrieitt.fo', (err, data) => {
if (err) {
return done(err);
}
assert.strictEqual(data, '');
done();
});
});
});

0 comments on commit 401fcc6

Please sign in to comment.