Skip to content

Commit

Permalink
refactor: simplify conditional statement for formatting OTX provider URL
Browse files Browse the repository at this point in the history
  • Loading branch information
lavafroth committed Jul 14, 2023
1 parent 95f15c5 commit 674f69e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions pkg/providers/otx/otx.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,17 @@ paginate:
}

func (c *Client) formatURL(domain string, page int) string {
category := "hostname"
if !domainutil.HasSubdomain(domain) {
return fmt.Sprintf(_BaseURL+"api/v1/indicators/domain/%s/url_list?limit=100&page=%d",
domain, page,
)
} else if domainutil.HasSubdomain(domain) && c.config.IncludeSubdomains {
return fmt.Sprintf(_BaseURL+"api/v1/indicators/domain/%s/url_list?limit=100&page=%d",
domainutil.Domain(domain), page,
)
} else {
return fmt.Sprintf(_BaseURL+"api/v1/indicators/hostname/%s/url_list?limit=100&page=%d",
domain, page,
)
category = "domain"
}
if domainutil.HasSubdomain(domain) && c.config.IncludeSubdomains {
domain = domainutil.Domain(domain)
category = "domain"
}

return fmt.Sprintf("%sapi/v1/indicators/%s/%s/url_list?limit=100&page=%d", _BaseURL, category, domain, page)

}

var _BaseURL = "https://otx.alienvault.com/"
Expand Down

0 comments on commit 674f69e

Please sign in to comment.