Skip to content

Commit

Permalink
fix URL normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
andpalmier committed Mar 24, 2024
1 parent bffa153 commit c35cfa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions cmd/seads/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (

/*
TODO
- export as text
- improve docker with alpine
- change User-Agent string
- Add more search engines
- handle errors :(
- export results as text
- change User-Agent stri
*/

var (
Expand Down
12 changes: 6 additions & 6 deletions cmd/seads/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func removeDuplicates(ads []string) ([]string, error) {
return results, nil
}

// normalizeURL normalizes an ad URL by adding "www." and "https://" if missing
// normalizeURL normalizes an ad URL by adding "https://" if missing
func normalizeURL(adURL string) string {
if !strings.Contains(adURL, "www.") {
adURL = "www." + adURL
if strings.HasPrefix(adURL, "https://") {
return adURL
}
if !strings.Contains(adURL, "https://") {
adURL = "https://" + adURL
if strings.HasPrefix(adURL, "http://") {
return strings.ReplaceAll(adURL, "http://", "https://")
}
return adURL
return "https://" + adURL
}

// EncodeString encodes an input string
Expand Down

0 comments on commit c35cfa7

Please sign in to comment.