From 75a58f465c18efc67a266cb34cfe89e598c6ec47 Mon Sep 17 00:00:00 2001 From: h345983745 Date: Thu, 7 Feb 2019 21:05:07 +0000 Subject: [PATCH] Removed jpath import --- src/core/operations/DNSOverHTTPS.mjs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/core/operations/DNSOverHTTPS.mjs b/src/core/operations/DNSOverHTTPS.mjs index 178c065..2cac79b 100644 --- a/src/core/operations/DNSOverHTTPS.mjs +++ b/src/core/operations/DNSOverHTTPS.mjs @@ -3,7 +3,6 @@ * @copyright Crown Copyright 2019 * @license Apache-2.0 */ -import jpath from "jsonpath"; import Operation from "../Operation"; import OperationError from "../errors/OperationError"; @@ -19,7 +18,7 @@ class HTTPSOverDNS extends Operation { super(); this.name = "DNS over HTTPS"; - this.module = "Code"; + this.module = "Default"; this.description = ["Takes a single domain name and performs a DNS lookup using DNS over HTTPS.", "

", "By default, Cloudflare and Google DNS over HTTPS services are supported.", @@ -93,7 +92,7 @@ class HTTPSOverDNS extends Operation { }) .then(data => { if (justAnswer) { - return jpath.query(data, "$.Answer[*].data"); + return this.extractData(data.Answer); } return data; @@ -104,6 +103,25 @@ class HTTPSOverDNS extends Operation { } + + /** + * Construct an array of just data from a DNS Answer section + * @private + * @param {JSON} data + * @returns {JSON} + */ + extractData(data) { + if (typeof(data) == "undefined"){ + return []; + } else { + const dataValues = []; + data.forEach(element => { + dataValues.push(element.data); + }); + return dataValues; + + } + } } export default HTTPSOverDNS;