<commit_before>package DDG::Spice::DNS;
# ABSTRACT: Gets IP address of given domain name.

use DDG::Spice;
use Data::Validate::Domain qw(is_domain);

spice to => 'http://pro.viewdns.info/dnsrecord/?domain=$1&recordtype=A&apikey={{ENV{DDG_SPICE_VIEWDNS_APIKEY}}}&output=json';

spice wrap_jsonp_callback => 1;

primary_example_queries 'dns viewdns.info';
description 'IP address of domain';
name 'DNS';
attribution github => ['https://www.github.com/OndroNR', '<NAME>'],
            twitter => ['https://www.twitter.com/OndroNR', '<NAME>'];

triggers any => 'dns', 'record';

spice from => '(.*)/(.*)';

handle query_lc => sub {
    s/(a)\s+record\s+//;
	my $valid = is_domain($_);
	return 'A', "$_" if $valid;
    return;
};

1;<commit_msg>accept and pass all DNS record types (default ANY)<commit_after>package DDG::Spice::DNS;
# ABSTRACT: Gets IP address of given domain name.

use DDG::Spice;
use Data::Validate::Domain qw(is_domain);

spice to => 'http://pro.viewdns.info/dnsrecord/?domain=$2&recordtype=$1&apikey={{ENV{DDG_SPICE_VIEWDNS_APIKEY}}}&output=json';

spice wrap_jsonp_callback => 1;

primary_example_queries 'dns viewdns.info';
description 'IP address of domain';
name 'DNS';
attribution github => ['https://www.github.com/OndroNR', '<NAME>'],
            twitter => ['https://www.twitter.com/OndroNR', '<NAME>'];

triggers any => 'dns', 'record';

spice from => '(.*)/(.*)';

handle query_lc => sub {
    s/(?:(a|aaaa|afsdb|apl|caa|cert|cname|dhcid|dlv|dname|dnskey|ds|hip|ipseckey|key|kx|loc|mx|naptr|ns|nsec|nsec3|nsec3param|ptr|rrsig|rp|sig|soa|spf|srv|sshfp|ta|tkey|tlsa|tsig|tx)\s+)?(record|dns)\s+//;
    my $record = defined $1 ? $1 : 'any';
	return uc $record, $_ if is_domain $_;
    return;
};

1;
{'fraction_non_alphanumeric': 0.20069605568445475, 'fraction_numerical': 0.0063805104408352666, 'mean_word_length': 5.412639405204461, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7017296', 'n_tokens_mistral': 702, 'n_tokens_neox': 687, 'n_words': 125}