diff --git a/main_test.go b/main_test.go index 829f123..f57043d 100644 --- a/main_test.go +++ b/main_test.go @@ -517,3 +517,12 @@ func TestMainResolveIPs(t *testing.T) { assert.Nil(t, err) assert.Regexp(t, regexp.MustCompile(`core1.fmt2.he.net. .* A .* \(core1.fmt2.he.net.\)`), out.String()) } + +func TestMainQueryDomainWithRRType(t *testing.T) { + out, err := run( + "NS.network", + "A", + ) + assert.Nil(t, err) + assert.Regexp(t, regexp.MustCompile(`NS.network. .* A .*`), out.String()) +} diff --git a/output/pretty.go b/output/pretty.go index e36d3a5..13c5135 100644 --- a/output/pretty.go +++ b/output/pretty.go @@ -90,7 +90,13 @@ func (e *Entry) parseRR(a dns.RR, opts *cli.Flags) *RR { e.existingRRs = make(map[string]bool) } - val := strings.TrimSpace(strings.Join(strings.Split(a.String(), dns.TypeToString[a.Header().Rrtype])[1:], "")) + val := a.String() + for _, cut := range []string{a.Header().Name, strconv.Itoa(int(a.Header().Ttl)), dns.ClassToString[a.Header().Class], dns.TypeToString[a.Header().Rrtype]} { + val = strings.TrimSpace( + strings.TrimPrefix(val, cut), + ) + } + rrSignature := fmt.Sprintf("%s %d %s %s %s", a.Header().Name, a.Header().Ttl, dns.TypeToString[a.Header().Rrtype], val, e.Server) // Skip if we've already printed this RR if ok := e.existingRRs[rrSignature]; ok {