Skip to content

Commit

Permalink
fixed a function bug
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4f53 committed Aug 10, 2024
1 parent 8819a53 commit dd34651
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions textsubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ type SubAndDom struct {
// removeDuplicates (bool) -> return only unique names
// keepDomains (bool) -> return domain even if domain does not contain a subdomain
// breakFused (bool) -> try and split fused subdomains and domains (e.g. www.0x4f.iniforgot.apple.com becomes [www.0x4f.in iforgot.apple.com])
func SubdomainAndDomainPair(text string, removeDuplicates bool, breakFused bool, keepDomains bool) ([]SubAndDom, error) {
func SubdomainAndDomainPair(text string, removeDuplicates bool, keepDomains bool, breakFused bool) ([]SubAndDom, error) {

var results []SubAndDom
subdomains, err := getSubdomains(text, breakFused)
Expand Down Expand Up @@ -253,20 +253,24 @@ func SubdomainAndDomainPair(text string, removeDuplicates bool, breakFused bool,
pair.Subdomain = item
pair.Domain = domain

if keepDomains {
if domain != item {
results = append(results, pair)
}
} else {
results = append(results, pair)
}
results = append(results, pair)

if removeDuplicates {
results = removeDuplicateSubAndDoms(results)
}

}

if !keepDomains {
var subsOnly []SubAndDom
for _, item := range results {
if item.Domain != item.Subdomain {
subsOnly = append(subsOnly, item)
}
}
results = subsOnly
}

return results, nil

}
Expand Down
2 changes: 1 addition & 1 deletion textsubs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestMyFunction(t *testing.T) {
t.Log("")

t.Log("Paired outputs: ")
output_pairs, err := SubdomainAndDomainPair(string(data), true, false, true)
output_pairs, err := SubdomainAndDomainPair(string(data), true, true, true)

if err != nil {
t.Error(err)
Expand Down

0 comments on commit dd34651

Please sign in to comment.